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

ContextMenu in GGC

Hi,

I have GGC and I want to show up a Contextmenu when a user clicks in the area of the GGC. The context menu should show up even if the user clicks in an area where no cells are.

So I think I can''t use the TableControlCellClick event here. Any ideas?

Thank you
Tom

3 Replies

AD Administrator Syncfusion Team August 31, 2006 02:06 PM UTC

Hi Tom,

Try handling the TableControlMouseDown event of the GridGroupingControl and show your contextmenu there.

private void gridGroupingControl1_TableControlMouseDown(object sender, GridTableControlMouseEventArgs e)
{
if(e.Inner.Button == MouseButtons.Right)
{
this.contextMenu1.Show(this.gridGroupingControl1, this.gridGroupingControl1.PointToClient(Control.MousePosition));
}
}

Regards,
Rajagopal


AD Administrator Syncfusion Team September 1, 2006 07:36 AM UTC

Hi,

thanks your solution works fine - but I have a got a further problem. I have also defined another context menu for a cell click (with a TableControlCellClick event). Now I want to disable the context menu for the TableControlMouseDown event if the user clicks on a cell - is this possible?

Currently there are two context menus shown if a user clicks on a cell (one for the TableControlMouseDown event and another for the TableControlCellClick)


AD Administrator Syncfusion Team September 4, 2006 07:46 AM UTC

Hi Tom,

Try the code below in the TableControlMouseDown event to conditionally display a context menu for the grid and not for cells.

private void gridGroupingControl1_TableControlMouseDown(object sender, GridTableControlMouseEventArgs e)
{
GridTableCellStyleInfo styleinfo = e.TableControl.PointToTableCellStyle(new Point(e.Inner.X, e.Inner.Y));
if(e.Inner.Button == MouseButtons.Right && styleinfo.TableCellIdentity.TableCellType == GridTableCellType.EmptyCell)
{
// show contextmenu1
this.contextMenu1.Show(this.gridGroupingControl1, this.gridGroupingControl1.PointToClient(Control.MousePosition));
}
}

private void gridGroupingControl1_TableControlCellClick(object sender, GridTableControlCellClickEventArgs e)
{
if(e.Inner.MouseEventArgs.Button == MouseButtons.Right)
{
// show contextmenu2
this.contextMenu2.Show(this.gridGroupingControl1, this.gridGroupingControl1.PointToClient(Control.MousePosition));
}
}

Let me kmow if this helps.
Regards,
Rajagopal

Loader.
Live Chat Icon For mobile
Up arrow icon