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

TableControlCellMouseUp and ContextMenu with GridGroupingcontrol

Initially I assigned a contextmenu to the GridGroupingControl. It worked fine. Since I need to differentiate if the context menu is on column header/regular cell/blank area, I added TableControlCellMouseUp handler. I found the context menu is not working after the handler is added. I can popup the context menu in header/cell, but I have no way to popup it in blank area. what''s the proper way to popup context menu in any situation? Thanks, albert

1 Reply

AD Administrator Syncfusion Team September 28, 2004 01:58 PM UTC

Currently, I think you will have to handle 2 events to catch both these situations. The grid.TableControl.MouseUp will catch the click where there are no cells.
this.gridGroupingControl1.TableControlCellMouseUp += new Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellMouseEventHandler(gridGroupingControl1_TableControlCellMouseUp);
this.gridGroupingControl1.TableControl.MouseUp += new MouseEventHandler(TableControl_MouseUp);

private bool TableControlCellMouseUpHit = false;

private void gridGroupingControl1_TableControlCellMouseUp(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellMouseEventArgs e)
{
	if(e.Inner.MouseEventArgs.Button == MouseButtons.Right)
	{
		TableControlCellMouseUpHit = true;
		this.contextMenu1.Show(this.gridGroupingControl1, 
			this.gridGroupingControl1.PointToClient(Control.MousePosition));
	}
}

private void TableControl_MouseUp(object sender, MouseEventArgs e)
{
	if(!TableControlCellMouseUpHit && e.Button == MouseButtons.Right)
		this.contextMenu1.Show(this.gridGroupingControl1, 
			this.gridGroupingControl1.PointToClient(Control.MousePosition));
	TableControlCellMouseUpHit = false;
}

Loader.
Live Chat Icon For mobile
Up arrow icon