public Form1() { InitializeComponent(); // cmb.SelectedIndex = 0; cmb.Items.Add("1"); cmb.Items.Add("2"); cmb.Items.Add("3"); cmb.Items.Add("4"); cmb.Items.Add("5"); cmb.Items.Add("6"); cmb.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; } private void cmb_Draw(object sender, DrawItemEventArgs e) { cmb.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; // Draw the background e.DrawBackground(); // Get the item text string text = ((ComboBox)sender).Items[e.Index].ToString(); // Determine the forecolor based on whether or not the item is selected Brush brush; if (int.Parse( text) > 3 ) // condition check { brush = Brushes.Red; } else { brush = Brushes.Blue; } // Draw the text e.Graphics.DrawString(text, ((Control)sender).Font, brush, e.Bounds.X, e.Bounds.Y);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)