为什么工具提示不显示? [英] Why is Tooltip not displaying?
本文介绍了为什么工具提示不显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在应用程序中添加了工具提示.
I added a Tooltip to my app.
在我希望它显示提示/工具提示的控件(一个DataGridView)中,我向工具提示"属性中添加了修饰语.但是我的语言不显示(准确地说,什么也没有.).
In the control (a DataGridView) where I want it to display the hint/tooltip, I added verbiage to the "Tooltip on " property. But my verbiage does not display (nothing does, to be precise).
为什么?
我在相关按钮上添加了单词,它工作正常.也许DGV本身无法处理工具提示?
I added verbiage to a related button, and it works just fine. Maybe the DGV itself cannot deal with tooltips?
已添加
这里是演示该问题的完整示例
Here is a complete sample that demonstrates the problem
using System;
using System.Drawing;
using System.Windows.Forms;
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
var form = new Form {
Controls = {
new Button { Name = "button", Location = new Point(10, 10) },
new DataGridView { Name = "dgv", Location = new Point(10, 50) },
},
};
var tooltip = new ToolTip();
tooltip.SetToolTip(form.Controls["button"], "Button Tooltip");
tooltip.SetToolTip(form.Controls["dgv"], "DGV Tooltip");
Application.Run(form);
GC.KeepAlive(tooltip); // it's cheaper than implementing IContainer on the form for this demo
}
}
推荐答案
我在这里找到了答案: DataGridViewToolTipText不显示
I found the answer here: DataGridView ToolTipText not showing
private void dgvPlatypus_CellToolTipTextNeeded(object sender, DataGridViewCellToolTipTextNeededEventArgs e)
{
e.ToolTipText = "j. cutworm is a punk";
}
这篇关于为什么工具提示不显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文