C# Win Forms – Tooltip for ComboBox Items

 

C# does not have tooltip facility for ComboBox items in Windows applications. If we require tooltip for comboBox list items, we have to add the DrawItem event for comboBox. In this article we discuss about how to add tooltip for comboBox items.

 

Create Windows application in C# and add one comboBox, one toolTip controls. Add some items to toolTip control. Add below code for DrawItem event as shown below.

 

private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)

{

            if (e.Index == -1) { return; }

            Point p = new Point(comboBox1.Location.X + 120, comboBox1.Location.Y + comboBox1.Height + (25 + e.Index * 10));

 

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)

            {

                toolTip1.Show(comboBox1.Items[e.Index].ToString(), this, p);

            }

 

            e.DrawBackground();

            e.Graphics.DrawString(comboBox1.Items[e.Index].ToString(), e.Font, Brushes.Black, new Point(e.Bounds.X, e.Bounds.Y));

}

 

Change the comboBox1 control DrawMode to “OwnerDrawFixed”. Now run the application and the output is as shown below.

 

                                                                                                         

                                                                                                       ToolTipComboBox.zip (40.33 kb)