1
votes

I need to implement datagridview selection in that way so when user clicks a cell whole row is selected, when user holds CTRL key additional rows are selected, when user holds SHIFT key range of rows are selected. According to requirement I cannot show RowHeaders so selection should be based on cell clicking. I also know that datagridview.SelectionMode = FullRowSelect will do the trick but I'm getting one problem when using SHIFT for selection - gaps. When someone selects one row, then presses SHIFT and then jumps over few row to select anoter not all cells became selected(look at the picture - rows with x=3,4,5 have cells which are not selected).

enter image description here

Help me to solve this problem.

Actually I have some ideas. For example, somehow treat clicking on a cell as clicking on a rowheader, but I'm not sure how to implement this.

1
I've tried to replicate your problem with no success - fullrowselect with no row headers and multiselect true works fine for both CTRL and SHIFT selects. Is there any other unusual code that you haven't shown in your question?David Hall

1 Answers

1
votes
datagridview.SelectionMode = FullRowSelect

and

datagridview.RowHeaderVisible=false