如何在C#窗体中设置自动完成组合框的工具提示? [英] How to set tool tip for autocomplete combobox in C# windows forms?

查看:114
本文介绍了如何在C#窗体中设置自动完成组合框的工具提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为组合框的列表项设置了工具提示,但我无法在cobmobox中搜索文本时出现的autocomeplete建议列表中设置工具提示。



如何设置在C#.net Winforms应用程序中使用自动完成组合框的建议项目上的工具提示。



我尝试过的方法:



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));
        }

推荐答案

请参阅此代码示例:[ ^ ]。



请参阅此CP文章:[ ^ ]和我的建议更改代码:[ ^ ]



如果这对您没有帮助,请告诉我。
See this code example: [^].

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

Let me know if this doesn't help you.

这篇关于如何在C#窗体中设置自动完成组合框的工具提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆