As we all know, the font color will be changed and drop-down options at the same time.
Independently draw the drop-down option font color, ForeColor is only effective for colors, example:
private void cb7_DrawItem(object sender, DrawItemEventArgs e) { DrawCboItems(sender, e); } private void cb7_SelectedIndexChanged(object sender, EventArgs e) { SetCboTextColor(sender); } private void SetCboTextColor(object sender) { ComboBox cbx = sender as ComboBox; if ( == "+") = ; else = ; } private void DrawCboItems(object sender, DrawItemEventArgs e) { ComboBox cbo = sender as ComboBox; //Initialize the font and background color Pen fColor = new Pen(); Pen bColor = new Pen(); switch () { //Index of drop-down options case 1: { fColor = new Pen(); break; } } (, ); ((string)[], , , ); }
The above is the detailed content of how Winform ComboBox can independently draw the font color of the drop-down option. For more information about Winform ComboBox to draw font color, please follow my other related articles!