【发布时间】:2012-09-14 22:26:17
【问题描述】:
我在我的应用中添加了一个工具提示。
在我希望它显示提示/工具提示的控件(DataGridView)中,我在“Tooltip on”属性中添加了措辞。但是我的措辞没有显示(准确地说,什么都没有)。
为什么?
我向相关按钮添加了措辞,它工作得很好。也许 DGV 本身无法处理工具提示?
已添加
这是一个演示问题的完整示例
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
}
}
【问题讨论】:
-
你能展示如何添加的代码示例吗?
-
这很容易复制。从这里复制和粘贴代码比将 DGV 和 ToolTip 拖放到表单上并设置 DGV 的扩展属性需要更长的时间。一个完全有效的问题。
-
无代码 - 我只是删除了组件,并将文本输入到 DGV 的属性中。
-
根据您的回答。 stackoverflow.com/questions/389439/… 的可能重复项
标签: c# winforms datagridview tooltip