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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Right Clicking for a ContextMenu

Thread ID:

Created:

Updated:

Platform:

Replies:

1367 Oct 22,2002 01:11 PM UTC Oct 22,2002 07:13 PM UTC WinForms 3
loading
Tags: GridControl
robert bergelson
Asked On October 22, 2002 01:11 PM UTC

I have added a context menu to the gridControl. When I run the application and right click on the grid, two things happen : A) The context pops up, and B) The underlying cell is selected How do I change this behavior so that only A) happens ? In other words when I right click over the grid, I want the pop up but not the selection of the underlying cell. Bob

Administrator [Syncfusion]
Replied On October 22, 2002 03:54 PM UTC

Bob, Here is a try at this behavior. It catches the CurrentCellDeactivvating, and if it is because of a rightmouse done, it cancels the current deactivating and the next deactivating. You have to cancel 2 because the cell tries to move when you do the mouseup as well. Regards, Clay
//class member...
bool skipDeactivate = false;
private void gridControl1_CurrentCellDeactivating(object sender, System.ComponentModel.CancelEventArgs e)
{
	if(Control.MouseButtons == MouseButtons.Right || skipDeactivate)
	{
		skipDeactivate = ! skipDeactivate;
		e.Cancel = true;
	}
}


robert bergelson
Replied On October 22, 2002 04:22 PM UTC

Clay, Thanks for the help, this works fine. I still see one minor behavior nit, on the first right mouse down, the underlying cell is still selected. Any way around this ? Bob

Administrator [Syncfusion]
Replied On October 22, 2002 07:13 PM UTC

Try moving that code from the CurrentCellDeactivating to the CurrentCellActivating event. bool skipActivate = false; private void gridControl1_CurrentCellActivating(object sender, Syncfusion.Windows.Forms.Grid.GridCurrentCellActivatingEventArgs e) { if(Control.MouseButtons == MouseButtons.Right || skipActivate) { skipActivate = ! skipActivate; e.Cancel = true; } }

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.

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

;