Hi, All.
I hold CTRL key and click on a row. Aftter this I have found that collection of selected grid rows do not contain the row I clicked on( with holding CTRL key).
But if I do the same with holding SHIFT key that collection of selected grid rows contains the row I clicked on.
Note:
- I mean the case when we are selecting only one row.
- I use grid.DisplayLayout.Override.CellClickAction = CellClickAction.RowSelect;
What is the reason of that? I need to add such row to grid.Selected.Rows at clicking on row with holding CTRL key.
Thanks in advance.
Alex.
Hi Alex,
I think you might be getting confused by the ActiveRow here.
When I run your sample application, the first row in the grid is Active (not selected). So if I click the button right away, the selected rows count is 0. The first row appears selected, but it's not, it's just the Active Row. So to avoid confusion, I turned I would turn off this active row appearance. FAQ:How do I turn off the ActiveRowAppearance so that the active row in the grid does not appear selected.
Now I try to follow your steps. I click on the second row. The second row is now highlighted. The second row is now both active and selected. The count is 1.
Now this is where you lost me. You say that step two is to hold CTRL and click on another row. If you hold CTRL and click on the second row, then this row, which is already selected, will now be de-selected. So the count is now 0. If you didn't reset the ActiveRowAppearance, then there will be no visible change in the row, but it is being de-selected. The CTRL key toggles the selection of an individual row.
The Shift key allows you to select a contiguous range of rows. That's the difference between Shift and Ctrl. Ctrl select individual, non-contigous rows while shift selects a range of contiguous rows. This is standard Windows behavior, it's nothing specific to the grid.
Mike, thanks for you quick answering my question.
We are using Infragistics 8.1 with HotFix_2033.
I have attached the small test project that demonstrates what I said about.
1. Select any one row without holding CTRL key and click on the button that is at the bottom of the form.
Result: 1 row selected.
2 .Select any one row with holding CTRL key and click on the button.
Result : 0 row selected.
3. Select any one row with holding SHIFT key and click on the button.
Result : 1 row selected.
I could not understand what is the difference between CTRL and SHIFT keys in this case? And how to achive that selected row(with CTRL) will be added to Selected.Rows collection ?
I tested this out with a new grid on a form and it works fine for me. So if it's not working for you, then it must be either an old bug in the grid or something in your code. Without more information, I'm afraid I really couldn't guess why it's happening.