Reputation: 26
I am working in .net winform application,in that datagridview is mandatory (single row select, read only).When I press Ctrl + Click my grid datagridview row is getting unselected,While I am trying to avoid this scenario I have used cellmouseclick event to validate which works fine except this scenario which is If I hold mouse click and released it outside of the datagridview the above not working.Please suggest
Upvotes: 0
Views: 1404
Reputation: 21
I appear to be the only other person who ran into this problem! In my case, I was clearing the current selections in the CellMouseDown handler and selecting the row that was just clicked on. I was doing this in order to allow a right-click to select a row. It was working fine, as long as Control was not pressed. I protected the code with a check for the Control key, and that worked:
if ((Control.ModifierKeys & Keys.Control) == 0)
{
myDataGrid.ClearSelection();
// ... additional code....
}
None of the other grids in our application had this issue, so maybe this is your situation, too?
Upvotes: 2