views:

196

answers:

2

HI,

using Syncfusions Gridlist control:

The user should be able to select various rows (1 or many), then I need a way to programmatically determine which rows are selected. I will be using a context menu on the grid, so I need to find which ones are selected at that point.

Any help with the above would be great

A: 

Check for a grid event that is triggered when you right click on the grid, and see what arguments are given to you (by using 'e').

Daryl
+1  A: 

Hi Brandon,

You can access the selected items like this:

 foreach (SelectedRecord selectedRecord in Grid.Table.SelectedRecords)
                {
                    TypeBoundToDataGrid typeBound= selectedRecord.Record.GetData() as TypeBoundToDataGrid ;

                }

Please Note: You will need to turn on the selection mode in the grid by doing this:

For MultiSelection:

Grid.TableOptions.ListBoxSelectionMode = SelectionMode.MultiExtended;
        Grid.TableOptions.AllowSelection = GridSelectionFlags.None;
        Grid.TableOptions.ListBoxSelectionColorOptions = GridListBoxSelectionColorOptions.ApplySelectionColor;
        Grid.TableOptions.ListBoxSelectionCurrentCellOptions = 
            GridListBoxSelectionCurrentCellOptions.WhiteCurrentCell 
            | GridListBoxSelectionCurrentCellOptions.MoveCurrentCellWithMouse;

For SingleSelection

Grid.TableOptions.ListBoxSelectionMode = SelectionMode.One;
        Grid.TableOptions.AllowSelection = GridSelectionFlags.None;
        Grid.TableOptions.ListBoxSelectionColorOptions = GridListBoxSelectionColorOptions.ApplySelectionColor;
        Grid.TableOptions.ListBoxSelectionCurrentCellOptions = 
            GridListBoxSelectionCurrentCellOptions.WhiteCurrentCell 
            | GridListBoxSelectionCurrentCellOptions.MoveCurrentCellWithMouse;

Josh

jj.matthews