I have a datagridview with both CellMouseDown and RowEnter event handlers. I use the CellMouseDown handler to detect if a header row or a data row was selected and which mouse button was used. If the user left clicks on a data row nothing really happens in CellMouseDown and the RowEnter event is fired which I use to populate an information pane for that row. The DGV is populated by manually creating a data table and setting it as the data source. As part of the data source loading process I set the current cell/row to be the first row.
The problem I am having is that after the data source is updated the very first mouse click in the DGV does not fire the CellMouseDown event. So if I select the last row the CellMouseDown doesn't fire, the RowEnter event fires with the DataGridViewCellEventArgs.RowIndex of zero every time, and the DGV leaves the first row selected. The second time I click it everything fires in the correct order (CellMouseDown, RowEnter) and it works as expected. To be absolutely clear, I am using the passed inDataGridViewCellEventArgs argument to retrieve the row index, I am not using the DGV's CurrentRow property.
In short, after setting the data source the first mouse click always appears to be the first row in the RowEnter handler regardless of what row was actually clicked upon.
Any ideas?
Thanks,
Bryan
The problem I am having is that after the data source is updated the very first mouse click in the DGV does not fire the CellMouseDown event. So if I select the last row the CellMouseDown doesn't fire, the RowEnter event fires with the DataGridViewCellEventArgs.RowIndex of zero every time, and the DGV leaves the first row selected. The second time I click it everything fires in the correct order (CellMouseDown, RowEnter) and it works as expected. To be absolutely clear, I am using the passed inDataGridViewCellEventArgs argument to retrieve the row index, I am not using the DGV's CurrentRow property.
In short, after setting the data source the first mouse click always appears to be the first row in the RowEnter handler regardless of what row was actually clicked upon.
Any ideas?
Thanks,
Bryan