How to change the ForeColor of individual items in a ComboBox? (C# Winforms)?

You can use DrawItem event This event is used by an owner-drawn ComboBox. You can use this event to perform the tasks needed to draw items in the ComboBox. If you have a variable sized item (when the DrawMode property set to DrawMode.

OwnerDrawVariable), before drawing an item, the MeasureItem event is raised. You can create an event handler for the MeasureItem event to specify the size for the item that you are going to draw in your event handler for the DrawItem event MSDN Example: You must handle the DrawItem event for owner-drawn combo boxes. // This event handler changes the color, size and font of an // item based on its position in the array.

Protected void ComboBox1_DrawItem(object sender, System.Windows.Forms. DrawItemEventArgs e) { float size = 0; System.Drawing. Font myFont; FontFamily family = null; System.Drawing.

Color animalColor = new System.Drawing.Color(); switch(e. Index) { case 0: size = 30; animalColor = System.Drawing.Color. Gray; family = FontFamily.

GenericSansSerif; break; case 1: size = 10; animalColor = System.Drawing.Color. LawnGreen; family = FontFamily. GenericMonospace; break; case 2: size = 15; animalColor = System.Drawing.Color.

Tan; family = FontFamily. GenericSansSerif; break; } // Draw the background of the item. E.DrawBackground(); // Create a square filled with the animals color.

Vary the size // of the rectangle based on the length of the animals name. Rectangle rectangle = new Rectangle(2, e.Bounds. Top+2, e.Bounds.

Height, e.Bounds. Height-4); e.Graphics. FillRectangle(new SolidBrush(animalColor), rectangle); // Draw each string in the array, using a different size, color, // and font for each item.

MyFont = new Font(family, size, FontStyle. Bold); e.Graphics. DrawString(animalse.

Index, myFont, System.Drawing.Brushes. Black, new RectangleF(e.Bounds. X+rectangle.

Width, e.Bounds. Y, e.Bounds. Width, e.Bounds.

Height)); // Draw the focus rectangle if the mouse hovers over an item. E. DrawFocusRectangle(); } EDIT : Just found a similar thread.

You can use DrawItem event. This event is used by an owner-drawn ComboBox. You can use this event to perform the tasks needed to draw items in the ComboBox.

If you have a variable sized item (when the DrawMode property set to DrawMode. OwnerDrawVariable), before drawing an item, the MeasureItem event is raised. You can create an event handler for the MeasureItem event to specify the size for the item that you are going to draw in your event handler for the DrawItem event.

MSDN Example: // You must handle the DrawItem event for owner-drawn combo boxes. // This event handler changes the color, size and font of an // item based on its position in the array. Protected void ComboBox1_DrawItem(object sender, System.Windows.Forms.

DrawItemEventArgs e) { float size = 0; System.Drawing. Font myFont; FontFamily family = null; System.Drawing. Color animalColor = new System.Drawing.Color(); switch(e.

Index) { case 0: size = 30; animalColor = System.Drawing.Color. Gray; family = FontFamily. GenericSansSerif; break; case 1: size = 10; animalColor = System.Drawing.Color.

LawnGreen; family = FontFamily. GenericMonospace; break; case 2: size = 15; animalColor = System.Drawing.Color. Tan; family = FontFamily.

GenericSansSerif; break; } // Draw the background of the item. E.DrawBackground(); // Create a square filled with the animals color. Vary the size // of the rectangle based on the length of the animals name.

Rectangle rectangle = new Rectangle(2, e.Bounds. Top+2, e.Bounds. Height, e.Bounds.

Height-4); e.Graphics. FillRectangle(new SolidBrush(animalColor), rectangle); // Draw each string in the array, using a different size, color, // and font for each item. MyFont = new Font(family, size, FontStyle.

Bold); e.Graphics. DrawString(animalse. Index, myFont, System.Drawing.Brushes.

Black, new RectangleF(e.Bounds. X+rectangle. Width, e.Bounds.

Y, e.Bounds. Width, e.Bounds. Height)); // Draw the focus rectangle if the mouse hovers over an item.E.

DrawFocusRectangle(); } EDIT : Just found a similar thread.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions