Click here to Skip to main content
15,915,163 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have set tooltip for List Items of combobox but i am not able set tooltip for autocomeplete suggest list which appears while searching text in cobmobox.

How to set tooltip on suggest items with autocomplete combobox in C#.net Winforms application.

What I have tried:

<pre>private void cmbGroupPractice_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index == -1)
            {
                return;
            }

            //user mouse is hovering over this drop-down item, update its data  
            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                // this tooltip simply shows the displayed text to the right of the drop-down  box, customize as needed  

                //toolTip1.Show(cmbGroupPractice.Items[e.Index].ToString(), cmbGroupPractice, e.Bounds.Right - 100 + e.Bounds.Height, e.Bounds.Top + e.Bounds.Width - 100);
                toolTip1.Show(cmbGroupPractice.Items[e.Index].ToString(), cmbGroupPractice, e.Bounds.Right - 100 + e.Bounds.Height, e.Bounds.Top + e.Bounds.Width - 100);
                
            }
            e.DrawBackground();
            // draw text strings  
            e.Graphics.DrawString(
                cmbGroupPractice.Items[e.Index].ToString(),
                e.Font,
                Brushes.Black, new Point(e.Bounds.X, e.Bounds.Y));
        }
Posted
Updated 19-Jan-17 2:28am
Comments
BillWoodruff 18-Jan-17 11:14am    
May I ask why you are making the choice to code using custom drawing ? Is the ToolTip ever visible ?
santosh vighne 19-Jan-17 0:59am    
Dropdown items does not show tooltip by default. Hence i written custom drawing to show tooltip

1 solution

See this code example: [^].

See this CP article: [^] And my suggested changes to the code: [^]

Let me know if this doesn't help you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900