Click here to Skip to main content
15,896,308 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: Please HELP!!!!!!! Pin
DampaZGB8-Jun-06 1:37
DampaZGB8-Jun-06 1:37 
AnswerRe: Please HELP!!!!!!! Pin
DampaZGB8-Jun-06 1:40
DampaZGB8-Jun-06 1:40 
GeneralRe: Please HELP!!!!!!! Pin
Robert Rohde8-Jun-06 2:02
Robert Rohde8-Jun-06 2:02 
AnswerRe: Please HELP!!!!!!! Pin
Eric Dahlvang8-Jun-06 4:30
Eric Dahlvang8-Jun-06 4:30 
GeneralRe: Please HELP!!!!!!! Pin
Colin Angus Mackay8-Jun-06 4:46
Colin Angus Mackay8-Jun-06 4:46 
GeneralRe: Please HELP!!!!!!! Pin
Ret Orrick8-Jun-06 7:42
Ret Orrick8-Jun-06 7:42 
GeneralRe: Please HELP!!!!!!! Pin
Colin Angus Mackay8-Jun-06 8:25
Colin Angus Mackay8-Jun-06 8:25 
GeneralRe: Please HELP!!!!!!! Pin
Ret Orrick8-Jun-06 8:40
Ret Orrick8-Jun-06 8:40 
GeneralRe: Please HELP!!!!!!! Pin
DampaZGB8-Jun-06 22:03
DampaZGB8-Jun-06 22:03 
Questionhow to send recived sms using smpp Pin
foysal mamun7-Jun-06 20:57
foysal mamun7-Jun-06 20:57 
QuestionCreating webpage using C# Pin
Vijju7-Jun-06 20:57
Vijju7-Jun-06 20:57 

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.