组合框上每个项目的工具提示,文本被剪切 [英] Tool tip for every item on combobox, text is getting clipped

查看:78
本文介绍了组合框上每个项目的工具提示,文本被剪切的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在C#.Net Windows应用程序上工作,我想显示组合框中每个项目的工具提示,因为某些项目的文本已被裁剪.这就是我目前在代码中所做的:

Hi All,

I am working on a C#.Net Windows application and I want to display tool tips for every item in a combobox as the text is getting clipped for some of the items. This is what I am presently doing in my code :

private void Form2_Load(object sender, EventArgs e)
{
    comboBox1.DrawMode = DrawMode.OwnerDrawFixed;
}

private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)
{
    string text = comboBox1.GetItemText(comboBox1.Items[e.Index]);
    e.DrawBackground();
    using (SolidBrush br = new SolidBrush(e.ForeColor))
    { e.Graphics.DrawString(text, e.Font, br, e.Bounds); }
    if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
    { toolTip1.Show(text, comboBox1, e.Bounds.Right, e.Bounds.Bottom); }
    e.DrawFocusRectangle();
}

private void comboBox1_DropDownClosed(object sender, EventArgs e)
{
    toolTip1.Hide(comboBox1);
}




我在这里面临的问题是,如果comboBox位于窗体的边缘附近(窗体以最大化模式打开),则工具提示会闪烁.

请提出解决方案.

提前致谢.

Gitika Khurana




The problem I am facing here is that if the comboBox is located near the edge of the form(the form opens in maximized mode), the tool tip flickers.

Please suggest a solution.

Thanks in advance.

Gitika Khurana

推荐答案



在Form_Load上将表单的DoubleBuffered属性设置为True.

Hi,

set DoubleBuffered property of the form to True on Form_Load.

this.DoubleBuffered = true;



这将消除闪烁.

希望这会有所帮助.

快乐编码:)



This will remove the flickering.

Hope this helps.

Happy Coding :)


这篇关于组合框上每个项目的工具提示,文本被剪切的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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