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



RB robert bergelson 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


AD Administrator Syncfusion Team 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; } }

Loader.
Up arrow icon