private void comboBox1_DrawItem(object sender, DrawItemEventArgs e) { e.DrawBackground(); e.Graphics.DrawString(comboBox1.Items[e.Index].ToString(), Font, Brushes.Black, e.Bounds); }
private void comboBox1_DropDown(object sender, EventArgs e) { Graphics g = comboBox1.CreateGraphics(); g.FillRectangle(Brushes.White, comboBox1.ClientRectangle); g.DrawLine(Pens.Black, 0, comboBox1.Height - 1, comboBox1.Width, comboBox1.Height - 1); g.DrawString("Item 1", comboBox1.Font, Brushes.Black, 5, 5); g.DrawString("Item 2", comboBox1.Font, Brushes.Black, 5, 25); g.Dispose(); }This code attaches an event handler to the DropDown event of the ComboBox control, which is fired when the drop-down menu is opened. The event handler then creates a new Graphics object using CreateGraphics(), and draws a custom drop-down menu using various GDI+ drawing methods. The package library for System.Windows.Forms ComboBox and CreateGraphics would be the .NET Framework Class Library, which is part of the .NET Framework SDK.