Click here to Skip to main content
15,910,234 members
Home / Discussions / C#
   

C#

 
Questioncomparision Pin
Mahmood Ilyas8-Jun-06 0:42
Mahmood Ilyas8-Jun-06 0:42 
AnswerRe: comparision Pin
Stephan Samuel8-Jun-06 0:52
Stephan Samuel8-Jun-06 0:52 
GeneralRe: comparision Pin
Mahmood Ilyas8-Jun-06 1:23
Mahmood Ilyas8-Jun-06 1:23 
Questionsignatures of a file [modified] Pin
Gulfaraz8-Jun-06 0:38
Gulfaraz8-Jun-06 0:38 
AnswerRe: signatures of a file [modified] Pin
Paul Brower8-Jun-06 1:45
Paul Brower8-Jun-06 1:45 
QuestionConnection Error Pin
pirogramci8-Jun-06 0:28
pirogramci8-Jun-06 0:28 
AnswerRe: Connection Error Pin
Stephan Samuel8-Jun-06 0:50
Stephan Samuel8-Jun-06 0:50 
AnswerRe: Connection Error Pin
alyeasad8-Jun-06 2:05
alyeasad8-Jun-06 2:05 
AnswerRe: Connection Error Pin
alyeasad8-Jun-06 2:09
alyeasad8-Jun-06 2:09 
AnswerRe: Connection Error Pin
pirogramci8-Jun-06 3:02
pirogramci8-Jun-06 3:02 
QuestionUrgent Pin
Shiv57-Jun-06 23:39
Shiv57-Jun-06 23:39 
AnswerRe: Urgent Pin
Colin Angus Mackay8-Jun-06 0:44
Colin Angus Mackay8-Jun-06 0:44 
AnswerRe: Urgent Pin
rfjeld8-Jun-06 0:52
rfjeld8-Jun-06 0:52 
AnswerRe: Urgent Pin
J4amieC8-Jun-06 1:08
J4amieC8-Jun-06 1:08 
GeneralRe: Urgent Pin
BoneSoft8-Jun-06 4:54
BoneSoft8-Jun-06 4:54 
JokeRe: Urgent Pin
Koushik Biswas8-Jun-06 8:16
Koushik Biswas8-Jun-06 8:16 
QuestionSetting default document in IIS 6.0 from commandline [modified] Pin
BhaskarJha7-Jun-06 23:30
BhaskarJha7-Jun-06 23:30 
QuestionListBox [modified] Pin
Nafiseh Salmani7-Jun-06 22:58
Nafiseh Salmani7-Jun-06 22:58 
AnswerRe: ListBox [modified] Pin
rfjeld7-Jun-06 23:23
rfjeld7-Jun-06 23:23 
You can set the color of individual items in a ListBox using C# in your .NET WinForm by writing your own handler for the listbox's DrawItem event.

Set the ListBox's DrawMode property:

Add a standard ListBox to your .NET WinForm then set it's DrawMode property to OwnerDrawFixed which forces the ListBox's DrawItem event to be fired.

Write the handler for the DrawItem event:

private void lstBox_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
{
//
// Draw the background of the ListBox control for each item.
// Create a new Brush and initialize to a Black colored brush by default.
//
e.DrawBackground();
Brush myBrush = Brushes.Black;
//
// Determine the color of the brush to draw each item based on
// the index of the item to draw.
//
switch (e.Index)
{
case 0:
myBrush = Brushes.Red;
break;
case 1:
myBrush = Brushes.Orange;
break;
case 2:
myBrush = Brushes.Purple;
break;
}
//
// Draw the current item text based on the current Font and the custom brush settings.
//
e.Graphics.DrawString(((ListBox)sender).Items[e.Index].ToString(),
e.Font, myBrush,e.Bounds,StringFormat.GenericDefault);
//
// If the ListBox has focus, draw a focus rectangle around the selected item.
//
e.DrawFocusRectangle();
}

In the InitializeComponent section associate your handler to the DrawItem event:

this.lstBox.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.lstBox_DrawItem);


QuestionProblem in getting value from Un-bounded DataGridViw. Pin
Mairaaj Khan7-Jun-06 22:13
professionalMairaaj Khan7-Jun-06 22:13 
QuestionPlease HELP!!!!!!! Pin
DampaZGB7-Jun-06 21:59
DampaZGB7-Jun-06 21:59 
AnswerRe: Please HELP!!!!!!! Pin
NaNg152417-Jun-06 22:10
NaNg152417-Jun-06 22:10 
AnswerRe: Please HELP!!!!!!! Pin
Colin Angus Mackay7-Jun-06 22:16
Colin Angus Mackay7-Jun-06 22:16 
GeneralRe: Please HELP!!!!!!! Pin
NaNg152417-Jun-06 22:36
NaNg152417-Jun-06 22:36 
GeneralRe: Please HELP!!!!!!! Pin
Colin Angus Mackay8-Jun-06 0:45
Colin Angus Mackay8-Jun-06 0:45 

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.