The sample and code that u shared looks a little close to my requirements.
I also added the following snippent to the code as i wanted that selection should not get lost till user clicks outside the range.
private void TableModel_SelectionChanging(object sender, GridSelectionChangingEventArgs e)
if (e.Reason == GridSelectionReason.MouseDown)
GridTableModel model = sender as GridTableModel;
GridRangeInfoList list = model.SelectedRanges;
foreach (GridRangeInfo range in list)
e.Cancel = true;
// Console.WriteLine("Count:" + " --- " + model.Table.Records.Count.ToString());
The problem is that as i am trying to simulate an excel like functionality, when user right clicks the grid after selecting a range, the selection should not be lost and a context menu should pop up which is applicable to selected range.
however, as happens in excel, if user left clicks on a selected range, the range selection should be cleared. Can you share some code to be able to achieve that
You can set the TableOptions.AllowSelection property to GridSelectionFlags.Any; in a grid and use TableModel.Selections property to manage the selection like get the selected row, add the selection,etc in a grid. Please find the code snippet below.
//Enable the cell based selection tech
this.gridGroupingControl1.TableOptions.AllowSelection = GridSelectionFlags.Any;
//Button click event
GridTableModel model = this.gridGroupingControl1.TableModel as GridTableModel;
foreach(GridRangeInfo info in model.Selections.GetSelectedRows(true,true))
for(int i = info.Top ; i<= info.Bottom ;i++)
//To get the selected records.
// and invalid the record here....
if( model.Table.DisplayElements[i].Kind == DisplayElementKind.Record)
Console.WriteLine(i +":::" + model.Table.DisplayElements[i].ParentRecord);
For more details about selection types, Seehttp://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=344