我如何设置autoPopDelay在一个DataGridView细胞工具提示? [英] How do I set the autoPopDelay for a tooltip in a DataGridView Cell?

查看:152
本文介绍了我如何设置autoPopDelay在一个DataGridView细胞工具提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我编程方式创建,我想通过设置的ToolTipText中的每一行的第一列/单元格设置不同的的ToolTipText为每行一个DataGridView。我知道我可以做到这一点的具体操作如下:

I have a dataGridView that I programatically create where I want to set the toolTipText differently for each row by setting the toolTipText in the first column/cell of each row. I know I can do that by doing the following:

myDataGridView.Rows(n).Cells(0).ToolTipText = varContainingText

这工作得很好。但是,它只显示了在默认时间段(5秒,我相信)。我想设置autoPopDelay,但似乎无法弄清楚如何。我似乎无法做这样的事情:

This works fine. However, it only displays for the default period of time (5 seconds I believe). I'd like to set the autoPopDelay but can't seem to figure out how. I can't seem to do something like:

myDataGridView.Rows(n).Cells(0).autoPopDelay = 10000

这是不是一个有效的参考。我如何设置autoPopDelay这个?

This is not a valid reference. How do I set the autoPopDelay for this?

推荐答案

您应该使用单独的工具提示的DataGridView,并使用CellMouseEnter事件设置文本的单元格。 DataGridView.ShowCellToolTips应设置为假。

You should use a separate ToolTip for the DataGridView and use the CellMouseEnter event to set the text for the cell. DataGridView.ShowCellToolTips should be set to False.

ToolTip toolTip1 = new ToolTip();
//....
private void dgv_Load(object sender, EventArgs e) 
{ 
toolTip1.AutomaticDelay = 100; 
toolTip1.AutoPopDelay= 1000; 
toolTip1.ReshowDelay = 100; 
dgv.ShowCellToolTips = false; 
} 

void dgv_CellMouseEnter(object sender, System.Windows.Forms.DataGridViewCellEventArgs e) 
{ 
    toolTip1.SetToolTip(dgv, dgv[e.ColumnIndex, e.RowIndex].Value.ToString()); 
} 

这篇关于我如何设置autoPopDelay在一个DataGridView细胞工具提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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