0

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

1 Answer 1

1

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.