I have a POS Touchscreen app. We use WinGrids in many places, one of the places entails a list of items in a grid, and the user can touch (click) each row he wants to select.
Because this is a touchscreen app, there is no shift, ctrl or right-click, only click or double click.
I have tried the following code.
private void _ultraGrid1_ClickCell(object sender, ClickCellEventArgs e){ if(_ultraGrid1.Selected.Rows.Count == 0) _ultraGrid1.PerformAction(UltraGridAction.ToggleRowSel, false, false); else _ultraGrid1.PerformAction(UltraGridAction.ToggleRowSel, true, false); }
I have set the row select mode to Extended, and I tried setting the cell click option to Default, SelectCell and the SelectRow, but it does not seem to work.
All I want is that when a user clicks on a row it will toggle the selection, i.e. if selected, unselect it, it not selected then select it. But in a way that the grid can have multiple rows selected.
I have been looking at this for a while, but cannot seem to find a way to do this.
On arelated subject, if I hold the shift key on my test maching, the multi-select works, so how do I do it wthout the select key?
Thanks
Hi,
There's really no way to do this with the grid's built-in selection. The grid will clear the selection any time you enter edit mode on a cell or click on a row without holding the shift key down.
What I would do is turn off the grid's built-in row selection behavior and implement selection on your own. This is not as difficult as it might seem.
I have attached a small sample project here which will get you most of the way there. The sample uses a grid with an unbound CheckBox column and keeps a collection of the checked rows and highlights them as though they are selected.
You can do something similar and just hide the CheckBox column and set the value of the cell in that column using the ClickRow event.