Click here to Skip to main content
15,918,268 members
Home / Discussions / C#
   

C#

 
GeneralRe: Random in C# Pin
Jakob Farian Krarup6-Apr-06 9:37
Jakob Farian Krarup6-Apr-06 9:37 
QuestionToolStripRenderer Pin
vishalkarlay6-Apr-06 6:49
vishalkarlay6-Apr-06 6:49 
AnswerRe: ToolStripRenderer Pin
Judah Gabriel Himango6-Apr-06 6:56
sponsorJudah Gabriel Himango6-Apr-06 6:56 
QuestionHow to declare virtual Columns Pin
mrkeivan6-Apr-06 6:20
mrkeivan6-Apr-06 6:20 
AnswerRe: How to declare virtual Columns Pin
Office Lineman6-Apr-06 8:42
Office Lineman6-Apr-06 8:42 
GeneralRe: How to declare virtual Columns Pin
mrkeivan6-Apr-06 9:11
mrkeivan6-Apr-06 9:11 
AnswerRe: How to declare virtual Columns Pin
Office Lineman6-Apr-06 9:30
Office Lineman6-Apr-06 9:30 
QuestionListBox problem Pin
Ready4u6-Apr-06 6:09
Ready4u6-Apr-06 6:09 
I've created a small application that print the content of a treeview and ListBox control.
It work's, but only if "DrawMode" is set to normal, when i try to change the value of this prop to OwnerDrawFixed and add this code :

private void LbDare_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)<br />
{<br />
Rectangle rc = new Rectangle(e.Bounds.X + delta , e.Bounds.Y + delta , e.Bounds.Width-10, e.Bounds.Height-delta);<br />
Console.WriteLine(e.State.ToString());<br />
<br />
StringFormat sf = new StringFormat();<br />
sf.Alignment = StringAlignment.Center;<br />
<br />
// UnBox the sender<br />
LbDare = (ListBox)sender ; <br />
<br />
// Get the item text<br />
string str = (string)LbDare.Items[e.Index];  <br />
Font font;<br />
if (TvDoc.SelectedNode != null)<br />
font = new System.Drawing.Font(TvDoc.SelectedNode.NodeFont.Name,TvDoc.SelectedNode.NodeFont.Size, TvDoc.SelectedNode.NodeFont.Style);<br />
else<br />
font = new System.Drawing.Font("Arial", 8);<br />
<br />
if ( e.State == ( DrawItemState.NoAccelerator | DrawItemState.NoFocusRect))<br />
e.Graphics.DrawString( str , font , new SolidBrush(Color.Black), rc);<br />
else<br />
e.Graphics.DrawString( str , font , new SolidBrush(Color.Red), rc);<br />
}


to formatting the text that appears, the preview dialog will replace the content of listbox with a totally-black box.

ps. the code below works only with default setting

<br />
// Create a single image from the content of treeview and listbox<br />
this._controlImage1 = GetImage(tree.Handle, tree.Width, tree.Height);<br />
this._controlImage2 = GetImage(ListB.Handle, ListB.Width, ListB.Height);<br />
<br />
System.Drawing.Size size = new Size(tree.Width + ListB.Width, tree.Height);<br />
Bitmap bmp = new Bitmap(size.Width,size.Height);<br />
Graphics g = Graphics.FromImage(bmp);<br />
<br />
g.DrawImage(this._controlImage1, 0,0,this._controlImage1.Width, this._controlImage1.Height);<br />
g.DrawImage(this._controlImage2, this._controlImage1.Width+1,5,ListB.ClientSize.Width, ListB.ClientSize.Height);<br />
<br />
this._controlImage = bmp;<br />
g.Save();<br />
g.Dispose();<br />
<br />
// This could create the image starting from the control passed by handle<br />
private Image GetImage(IntPtr handle, int width, int height) {<br />
	IntPtr screenDC = GetDC(IntPtr.Zero);<br />
	IntPtr hbm = CreateCompatibleBitmap(screenDC, width, height);<br />
	Image image = Bitmap.FromHbitmap(hbm);<br />
	Graphics g = Graphics.FromImage(image);<br />
	IntPtr hdc = g.GetHdc();<br />
	SendMessage(handle, 0x0318 /*WM_PRINTCLIENT*/, hdc, (long)(0x00000010 | 0x00000004 | 0x00000002));<br />
	g.ReleaseHdc(hdc);<br />
	ReleaseDC(IntPtr.Zero, screenDC);<br />
	return image;<br />
}<br />


Please help me... i'm so confused Sigh | :sigh:




Sorry for my little english... i'm italian...
AnswerRe: load + save ADO.NET and c# Pin
Judah Gabriel Himango6-Apr-06 5:40
sponsorJudah Gabriel Himango6-Apr-06 5:40 
Questionsql command + datagridView Problem Pin
mrkeivan6-Apr-06 5:14
mrkeivan6-Apr-06 5:14 
Questiondbf database files import net2.0 Pin
hpetriffer6-Apr-06 4:44
hpetriffer6-Apr-06 4:44 
QuestionDataGrid in .net 1.1 and 2.0 ??? Pin
amin_behzadi6-Apr-06 4:41
professionalamin_behzadi6-Apr-06 4:41 
AnswerRe: DataGrid in .net 1.1 and 2.0 ??? Pin
NeelV7-Apr-06 2:49
NeelV7-Apr-06 2:49 
QuestionMoving files programatically Pin
naglbitur6-Apr-06 4:14
naglbitur6-Apr-06 4:14 
AnswerRe: Moving files programatically Pin
Judah Gabriel Himango6-Apr-06 4:28
sponsorJudah Gabriel Himango6-Apr-06 4:28 
GeneralRe: Moving files programatically Pin
naglbitur6-Apr-06 5:09
naglbitur6-Apr-06 5:09 
GeneralRe: Moving files programatically Pin
Judah Gabriel Himango6-Apr-06 5:16
sponsorJudah Gabriel Himango6-Apr-06 5:16 
QuestionDirectory listing Pin
wistiti56-Apr-06 3:51
wistiti56-Apr-06 3:51 
AnswerRe: Directory listing Pin
Judah Gabriel Himango6-Apr-06 4:37
sponsorJudah Gabriel Himango6-Apr-06 4:37 
QuestionTreeView dilema. Please Help! Pin
zaboboa6-Apr-06 3:43
zaboboa6-Apr-06 3:43 
AnswerRe: TreeView dilema. Please Help! Pin
Judah Gabriel Himango6-Apr-06 4:46
sponsorJudah Gabriel Himango6-Apr-06 4:46 
GeneralRe: TreeView dilema. Please Help! Pin
zaboboa6-Apr-06 5:22
zaboboa6-Apr-06 5:22 
GeneralRe: TreeView dilema. Please Help! Pin
Judah Gabriel Himango6-Apr-06 5:32
sponsorJudah Gabriel Himango6-Apr-06 5:32 
QuestionProgramming windows form in .NET Pin
bluehai6-Apr-06 3:26
bluehai6-Apr-06 3:26 
AnswerRe: Programming windows form in .NET Pin
scoroop6-Apr-06 3:43
scoroop6-Apr-06 3:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.