How to set autoPopDelay for tooltip in a DataGridView cell?

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

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

It works great. However, it only displays for the default time period (think 5 seconds). I would like to install autoPopDelay, but cannot figure out how to do this. I can not do something like:

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

This is not a valid link. How to set autoPopDelay for this?

+2
source share
1 answer

You must use a separate tooltip for the DataGridView and use the CellMouseEnter event to set the text for the cell. DataGridView.ShowCellToolTips must 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()); } 
+3
source

All Articles