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

Context Menu Issue

Thread ID:





23152 Jan 5,2005 06:39 PM UTC Jan 5,2005 09:00 PM UTC WinForms 3
Tags: GridControl
Zubin Tiku
Asked On January 5, 2005 06:39 PM UTC

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

Administrator [Syncfusion]
Replied On 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.

Zubin Tiku
Replied On 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?

Administrator [Syncfusion]
Replied On 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


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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

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