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. Image for the cookie policy date
close icon

Excel like selection

Hi Again,

I am trying to achieve something how it is possible in excel.

If a user selects a number of records and
(1) Right clicks over the selected cells, excel then still select all the records and shows the pop up menu
(2) On right clicking outside the selected cells, excel un-select the previous selected cell, select the current row and shows the pop up menu

Can you please suggest how to do the same using Gridgroupingcontrol

I have tried using AnyRangeIntersects but gridGroupingControl.TableModel.Selections.GetSelectedRows(false, true) always return 1

Thanks


3 Replies

VK Vishnu Kumar Syncfusion Team February 15, 2008 02:07 PM UTC


Hi John

Thank you for your patience.

Issue 1:Right clicks over the selected cells, excel then still select all the records and shows the popup menu

Yes . It is possible to select all the record and able to show the popup menu when right clicking the mouse on the selected cells in Gridgroupingcontrol. The following code snippet is used to achieve this behavior.


gridGroupingControl1.TableOptions.ListBoxSelectionMode = SelectionMode.MultiExtended;
this.gridGroupingControl1.TableControl.Model.Options.SelectCellsMouseButtonsMask = MouseButtons.Left;


Issue 2: On right clicking outside the selected cells, excel un-select the previous selected cell, select the current row and shows the popup menu

No. It's not possible to deselect the selected rows by mouse right click when SelectCellsMouseButtonsMask property is set to left .Because we can set the SelectCellsMouseButtonsMask either left of right.

Please refer the sample in the below link which illustrates the above:

http://www.syncfusion.com/support/user/uploads/71815_14242cc5.zip

Please try running the above sample and let me know if this helps.

Regards,
Vishnu.





JR John Ruiz February 15, 2008 03:24 PM UTC



>
Hi John

Thank you for your patience.

Issue 1:Right clicks over the selected cells, excel then still select all the records and shows the popup menu

Yes . It is possible to select all the record and able to show the popup menu when right clicking the mouse on the selected cells in Gridgroupingcontrol. The following code snippet is used to achieve this behavior.


gridGroupingControl1.TableOptions.ListBoxSelectionMode = SelectionMode.MultiExtended;
this.gridGroupingControl1.TableControl.Model.Options.SelectCellsMouseButtonsMask = MouseButtons.Left;


Issue 2: On right clicking outside the selected cells, excel un-select the previous selected cell, select the current row and shows the popup menu

No. It's not possible to deselect the selected rows by mouse right click when SelectCellsMouseButtonsMask property is set to left .Because we can set the SelectCellsMouseButtonsMask either left of right.

Please refer the sample in the below link which illustrates the above:

http://www.syncfusion.com/support/user/uploads/71815_14242cc5.zip

Please try running the above sample and let me know if this helps.

Regards,
Vishnu.





If the second is not possible can't we achieve the same programmatically atleast? How about subscribing to cell click or table mosue down event? and then unselecting the selected rows when the cell is out of the selected records range? Could you tell me how to find if the selected cell is with in the selected range or records or not?

Thanks a bunch.

Cheers



HA haneefm Syncfusion Team April 12, 2008 12:10 AM UTC

Hi John,

You can handle the TableControlMouseDown event and track the GridTableCellStyleInfo for the clicked cell. Then in your event handler, you can access the TableCellIdentity for this saved style. This object has complete information for the Table which you can access through the DisplayElement.

private void gridGroupingControl1_TableControlMouseDown(object sender, GridTableControlMouseEventArgs e)
{
Point pt = new Point(e.Inner.X, e.Inner.Y);
GridTableCellStyleInfo style = this.gridGroupingControl1.TableControl.PointToTableCellStyle(pt);
Element el = style.TableCellIdentity.DisplayElement;

if(Control.MouseButton == MouseButton.Right)
{
el.ParentTable.SelectedRecords.Clear();
}
}

Best regards,
Haneef



Loader.
Live Chat Icon For mobile
Up arrow icon