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

Right Clicking for a ContextMenu

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

3 Replies

AD Administrator Syncfusion Team October 22, 2002 11:54 AM

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;
	}
}



RB robert bergelson October 22, 2002 12:22 PM

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


AD Administrator Syncfusion Team October 22, 2002 03:13 PM

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; } }

Loader.
Live Chat Icon For mobile
Up arrow icon