DataGridView.RowPostPaint event, e.RowIndex is out of range

  • Thread starter Thread starter Norman Diamond
  • Start date Start date
N

Norman Diamond

Using C# in VS 2005 SP1 with .Net Framework 2 SP1, I have the following
code:

private void MyDataGridView_RowPostPaint(object sender,
DataGridViewRowPostPaintEventArgs e)
{
DataGridViewRow gridRow = MyDataGridView.Rows[e.RowIndex];
// ....

and it crashes because e.RowIndex is larger than the number of rows in
MyDataGridView.

It's pretty obvious how to code a workaround for this bug, but it seems ...
hmm, maybe no dumber than usual.
 
I've seen a similar issue caused by a bug that was introduced in .NET 2.0 SP1
in the DataView. Are you bound to a DataView? Can you test the code on a
machine without 2.0SP1 installed on it?

Rob
 
Back
Top