private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)
{
ComboBox cbo = sender as ComboBox;
string str = Convert.ToString(cbo.Items[e.Index]);
Point loc = new Point
{
X = e.Bounds.Location.X,
Y = e.Bounds.Location.Y + Convert.ToInt32((e.Bounds.Height - e.Graphics.MeasureString(str, cbo.Font).Height)/2)
};
Brush foreBrush = Brushes.Black;
Brush backBrush = null;
if (شرط)
{
backBrush = Brushes.Red;
}
else
{
backBrush = Brushes.White;
}
e.Graphics.FillRectangle(backBrush, e.Bounds);
e.Graphics.DrawString(str, cbo.Font, foreBrush, loc);
}