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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Right Click Context Menu Location

Thread ID:





11008 Feb 19,2004 04:29 PM UTC Feb 19,2004 08:21 PM UTC WinForms 3
Tags: GridControl
John Bowm
Asked On February 19, 2004 04:29 PM UTC

Hi, Now that you''ve solved my previous problem, I noticed another issue that I can''t seem to figure out. I''ve got the Right Click context menu coming up fine when the user Right clicks on the GridControl and the SelectCellsMouseButtonsMask is set and working great. However, if the location where the user happens to right click is on the area of the grid that has no cells (say, way off to the right in the blank area) they still get the context menu (which makes no sense to me). Is there anyway to suppress the context menu popup when the right click is NOT on selected cells? TIA,

Administrator [Syncfusion]
Replied On February 19, 2004 05:41 PM UTC

If you are using something lik eth etechique in this KB, http://www.syncfusion.com/Support/article.aspx?id=10054, you can check to see if you are over a row, col before showing the menu.
private void gridControl1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
	if(e.Button == MouseButtons.Right)
		Point clickPoint = gridControl1.PointToClient(Cursor.Position);
		int rowIndex, colIndex;
		if(this.gridControl1.PointToRowCol(clickPoint, out rowIndex, out colIndex, -1))
			//make sure there is a selections of some type
			Syncfusion.Windows.Forms.Grid.GridRangeInfoList rangeList = null;
			//if no selections or current cell, use the rightclick point
			if(!gridControl1.Selections.GetSelectedRanges(out rangeList, true))
				gridControl1.CurrentCell.Activate(rowIndex, colIndex);
			contextMenu1.Show(gridControl1, clickPoint);

John Bowm
Replied On February 19, 2004 07:18 PM UTC

Clay, Thanks again for the help. However, I still can''t make it work implementing your code. When the following line fails, the context menu still appears even though the routine exits :(. What gives? if(this.gridControl1.PointToRowCol(clickPoint, out rowIndex, out colIndex, -1)) TIA, John

Administrator [Syncfusion]
Replied On February 19, 2004 08:21 PM UTC

Are you setting the ContextMenu property of the grid? If so, the .Net Framework will display the menu when ever you rightclick on the control (whether you are over a grid cell or not). The KB techniquw does not set the grid''s ContextMenu property. Instead, it explicitly calls contextMenu1.Show to display the menu, and does not rely on the framework to display it.


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

This page will automatically be redirected to the 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

Live Chat Icon For mobile
Live Chat Icon