I am currently building a user control that includes a Syncfusion Grid.
I would like to allow users to select a set of one or more rows within the grid and then right click to view a context menu where they can take actions on the rows they have selected. Currently I am encountering difficulty figuring out how to configure the Grid so that right clicking for the context menu does not affect the selected rows.
It seems that whatever I set the ListBoxSelectionMode of the grid to, the selection is invariably compromised and I cannot track down the event that is being raised that I need to handle to prevent this from happenning.
Thanks for any help,
ADAdministrator Syncfusion Team January 5, 2005 02:13 PM
This property setting should prevent the right-click from clearing the selections.
this.gridControl1.Model.Options.SelectCellsMouseButtonsMask = MouseButtons.Left;
If you want to control the context menus of active cell controls, you may need to use the technique discussed in this thread.
ZTZubin TikuJanuary 5, 2005 02:45 PM
Is there any way of getting the Grid to behave like an Excel spreadsheet?
When the user right clicks within a selected range of cells the selection is not affected, but if the user right clicks outside of a selected range of cells, the selection is updated?
ADAdministrator Syncfusion Team January 5, 2005 04:00 PM
If you want this behavior, do not set the SelectCellsMouseButtonMask. Instead, handle the SelectionsChanging event, and set e.Cancel = true if you right-click on selected cells.
Private Sub SelectionChanging(ByVal sender As Object, ByVal e As GridSelectionChangingEventArgs)
If e.Reason = GridSelectionReason.MouseDown And Control.MouseButtons = MouseButtons.Right Then
Dim row, col As Integer
Dim pt As Point = Me.GridDataBoundGrid1.PointToClient(Control.MousePosition)
If Me.GridDataBoundGrid1.PointToRowCol(pt, row, col, -1) Then
Dim rangeList As GridRangeInfoList
rangeList = Me.GridDataBoundGrid1.Selections.GetSelectedRows(True, False)
If rangeList.AnyRangeIntersects(GridRangeInfo.Cell(row, col)) Then
e.Cancel = True