How to add tooltips for each item in Combobox

I have been looking for various solutions, but no one has given me a direct answer or written on vb.net. But my situation is that I have ComboBoxwith several elements that the user can select. I want to add simple tips so that every user knows what he or she chooses. However, a tooltip is not displayed until an item is selected. I want the tooltip to show when the mouse hangs over each element.

Below is my code:

Private Sub VotingAgentComboBox_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VotingAgentComboBox.MouseHover
    Dim VotingAgentToolTip As New ToolTip
    If VotingAgentComboBox.Text = "ISS" Then VotingAgentToolTip.SetToolTip(VotingAgentComboBox, "You selected ISS")
End Sub
+3
source share
1 answer

try this .. Add a tooltip to manage your Forms and write this code in the DrawItem event to manage the list with the list

drawmode combobox, OwnerDrawFixed

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

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



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

                toolTip.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));
+1

All Articles