Tooltip for Combobox
-
Hi all There is a very peculiar requirement on a screen on one of the application i am working on. I need to show tool tip on every member of dropdownlist (when the list is open) Is there any way we can do that... If you have some hints please share. Thanks in advance
Vikram I Code...
-
Hi all There is a very peculiar requirement on a screen on one of the application i am working on. I need to show tool tip on every member of dropdownlist (when the list is open) Is there any way we can do that... If you have some hints please share. Thanks in advance
Vikram I Code...
Hope this helps: - Change the DrawMode property of your combo box to OwnerDrawFixed. - Implement the event DrawItem of the combo box and write there something like this:
ToolTip tt = new ToolTip(); private void comboBox1\_DrawItem(object sender, DrawItemEventArgs e) { e.DrawBackground(); e.Graphics.DrawString(comboBox1.Items\[e.Index\].ToString(), e.Font, e.State == DrawItemState.Selected ? Brushes.White : Brushes.Black, e.Bounds, StringFormat.GenericDefault); e.DrawFocusRectangle(); tt.Show(comboBox1.Items\[e.Index\].ToString(), comboBox1, 1000); }
This event is now called whenever an item is displayed. Now you have to insert the text that draws the combo items and, by the way, you update the tool tip with the information you want to show about the item.