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

Right Click Context Menu Location

Thread ID:

Created:

Updated:

Platform:

Replies:

11008 Feb 19,2004 11:29 AM Feb 19,2004 03:21 PM Windows Forms 3
loading
Tags: GridControl
John Bowm
Asked On February 19, 2004 11:29 AM

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 12:41 PM

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 02:18 PM

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 03:21 PM

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.

CONFIRMATION

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.

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.

;