开发者

How do I set the autoPopDelay for a tooltip in a DataGridView Cell?

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

This works fine. However, it only displays for the default period of time (5 secon开发者_Python百科ds 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

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


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜