grid selecting multiple rows

Hi,

I want to be able to do a delete on multiple rows for the grid control. I am using windows forms, C#

I have a grid with a context menu
On right click, the user can choose to add, delete.

He could select some rows and choose to delete all at once.

How do I enable selection of multiple rows. and then delete
What events should I use.

Thanks
Smitha



3 Replies

MC Mercy C Syncfusion Team March 30, 2012 01:49 PM UTC

Hi Smitha,

Thanks for your interest in Syncfusion products.

To select multiple rows, set the "ListBoxselectionMode" to "MultiExtended".

this.gridControl1.ListBoxSelectionMode = SelectionMode.MultiExtended;

You can handle "contextMenuStrip1.ItemClicked" to check if the menu option selected is "Delete" to delete the rows from the grid.

void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
if (e.ClickedItem.Text == "Delete")
{
if (this.gridControl1.Selections.Count > 0)
{
GridRangeInfoList ranges = this.gridControl1.Selections.Ranges;
foreach (GridRangeInfo r in ranges)
{
this.gridControl1.Rows.RemoveRange(r.Top, r.Bottom);
}
}
}
}

Please refer to the sample in the following link
http://www.syncfusion.com/downloads/Support/DirectTrac/89778/WindowsFormsApplication76-243854808.zip

Regards,
Mercy.C



SM Smitha April 5, 2012 04:23 PM UTC

Hi Mercy,

What is the difference between
theGrid.Model.Options.SelectCellsMouseButtonsMask = MouseButtons.Left;
this.theGrid.AllowSelection = Syncfusion.Windows.Forms.Grid.GridSelectionFlags.Any;

and

theGrid.ListBoxSelectionMode = SelectionMode.MultiExtended;

Thanks
Smitha



RB Ragamathulla B Syncfusion Team April 10, 2012 04:20 AM UTC

Hi Smitha,

Thank you for your interest in syncfusion products,

Please refer to the following UG link which is help to know the differences.


http://help.syncfusion.com/ug_94/User%20Interface/Windows%20Forms/Grid/Documents/43462recordbasedselection.htm


http://help.syncfusion.com/ug_94/User%20Interface/Windows%20Forms/Grid/Documents/41423selectionmodes.htm


You can have context menu on right click on column headers by using ‘TableControlCellClick’ event along with the following code. Please refer the following code to achieve the behavior.

Sample link:

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=847071641385806.zip

Let me know if you have any further concerns.


Regards,
Ragamathullah B.


Loader.
Up arrow icon