Line Separator between combobox items



Solution:

 

        private void Form1_Load(object sender, EventArgs e)

        {

// you have to chnage drawmode from Normal to OwnerDrawFixed

            comboBox1.DrawMode = DrawMode.OwnerDrawFixed;

            comboBox1.DrawItem += new DrawItemEventHandler(comboBox1_DrawItem);

        }

 

 

 

// on DrawItem write the code for DrawLine

        void comboBox1_DrawItem(object sender, DrawItemEventArgs e)

        {

            e.DrawBackground();

            e.Graphics.DrawLine(Pens.Red, new Point(e.Bounds.Left, e.Bounds.Bottom - 1),

              new Point(e.Bounds.Right, e.Bounds.Bottom - 1));

            TextRenderer.DrawText(e.Graphics, comboBox1.Items[e.Index].ToString(),

              comboBox1.Font, e.Bounds, comboBox1.ForeColor, TextFormatFlags.Left);

            e.DrawFocusRectangle();

        }