We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Selecting records in GCC

Thread ID:

Created:

Updated:

Platform:

Replies:

58194 Mar 20,2007 04:12 PM UTC Mar 27,2007 01:02 PM UTC WinForms 5
loading
Tags: GridControl
dinesh upreti
Asked On March 20, 2007 04:12 PM UTC

hi,

I have a requirement like this.

A user can select a single record by left clicking on that record’s row header, or can alternatively select multiple records by using CTRL+Click and/or SHIFT+Click.

I want to de some further processing on the selected records. So i should be able to capture the selected records

I am using Grid Grouping control.

Can you share some sample to achieve this.

Administrator [Syncfusion]
Replied On March 20, 2007 04:36 PM UTC

Hi Dinesh,

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, See
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=344

Regards,
Haneef

dinesh upreti
Replied On March 26, 2007 01:28 PM UTC

hi,

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)
{
Console.WriteLine("SelectionChanging:"+" Range"+e.Range.ToString());
if (e.Reason == GridSelectionReason.MouseDown)
{
GridTableModel model = sender as GridTableModel;
GridRangeInfoList list = model.SelectedRanges;
foreach (GridRangeInfo range in list)
{
if (range.IntersectsWith(e.ClickRange))
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


>Hi Dinesh,

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, See
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=344

Regards,
Haneef

Rajagopal [Syncfusion]
Replied On March 27, 2007 12:23 AM UTC

Hi Dinesh,

Please use the below property setting to prevent right click from affecting any selections. This will help you.

this.gridGroupingControl1.TableModel.Options.SelectCellsMouseButtonsMask = MouseButtons.Left;

Regards,
Rajagopal

dinesh upreti
Replied On March 27, 2007 12:43 PM UTC

Thanks.

Can you also tell me how to programatically clear any range or cell selections made in a grid, say on the click of a button.

Thanks

Dinesh Upreti

>Hi Dinesh,

Please use the below property setting to prevent right click from affecting any selections. This will help you.

this.gridGroupingControl1.TableModel.Options.SelectCellsMouseButtonsMask = MouseButtons.Left;

Regards,
Rajagopal

Jeba S [Syncfusion]
Replied On March 27, 2007 01:02 PM UTC

Hi Dinesh,

To clear any selections, please try this code snippet:

this.gridGroupingControl1.TableControl.Selections.Clear()
this.gridGroupingControl1.TableControl.SelectRecords.Clear()


Kindly let us know if this helps.

Best Regards,
Jeba.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;