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

Context Menu Issue

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, Zubin

3 Replies

AD Administrator Syncfusion Team January 5, 2005 07:13 PM UTC

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. http://64.78.18.34/Support/Forums/message.aspx?MessageID=13861


ZT Zubin Tiku January 5, 2005 07:45 PM UTC

Is there any way of getting the Grid to behave like an Excel spreadsheet? I.E. 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?


AD Administrator Syncfusion Team January 5, 2005 09:00 PM UTC

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
			End If
		End If
	End If
End Sub

Loader.
Live Chat Icon For mobile
Up arrow icon