I'm working in C# in Visual Studio. I have a DataGridView with a large amount of data (i.e 100+ columns, 1000+ rows). I've set the DataGridView to be double buffered and the user interaction and scrolling are working well. My DataGridView is called "ws" in the code below:
typeof(DataGridView).InvokeMember("DoubleBuffered", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetProperty, null, ws, new object[] { true });
Now, I'm trying to add tool tips that are dependent on the contents of the cells. I set up a DataGridViewCellToolTipTextNeededEventHandler, but the tool tips only show intermittently.
When the DataGridView first loads, the tool tips show fine. If I scroll slowly down, the tool tips show fine. However, if I grab the scroll bar and move quickly to the middle or bottom of the grid, the tool tips stop working. Scrolling back up to the top of the grid restores the tool tip functionality.
Here is my code for setting the tool tips:
this.ws.CellToolTipTextNeeded += new System.Windows.Forms.DataGridViewCellToolTipTextNeededEventHandler(ws_cellToolTipTextNeeded);
private void ws_cellToolTipTextNeeded(object sender, DataGridViewCellToolTipTextNeededEventArgs e)
{
if (e.RowIndex < 0 || e.ColumnIndex > 1) return; // only want tool tips on 0th and 1st column
String rowType = ws.Rows[e.RowIndex].Cells[0].Value.ToString().ToUpper();
e.ToolTipText = toolTip(rowType);
}
In my code, toolTip(rowType) is a function that returns a String based on the type of row which is defined in the 0th column.
I've tried turning off the double buffering, but the problem remains. Not sure what else to investigate.
Thoughts/Suggestions? Mike