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

Pop up menu manager for grid grouping control

Thread ID:

Created:

Updated:

Platform:

Replies:

57985 Mar 15,2007 11:14 AM UTC Mar 16,2007 02:20 PM UTC WinForms 3
loading
Tags: GridControl
dinesh upreti
Asked On March 15, 2007 11:14 AM UTC

Hi,
Which searching for managing contect menues, I stumbled upon this message in you forum

http://www.syncfusion.com/Support/forums/message.aspx?MessageID=5109

The sample reference in very colse to what i am looking for. But the problem is that i am working on grid grouping control which has a very different set of properties.

Can you help in translating the following piece of code to implement in GCC

private void dgRangePlanGrid_MouseUp(object sender, MouseEventArgs e)
{
if(e.Button == MouseButtons.Right)
{
GridCurrentCell cc = this.gridControl1.CurrentCell;
Point pt = new Point(e.X, e.Y);

Control c;
int row;
int col;
GridControlBase grid = sender as GridControlBase;
if(grid == null)
{
c = cc.Renderer.Control;
row = cc.RowIndex;
col = cc.ColIndex;
}
else
{
c = grid;
grid.PointToRowCol(pt, out row, out col, -1);

}
this.contextMenu1.MenuItems.Clear();
this.contextMenu1.MenuItems.Add(new MenuItem(string.Format("menuForCell({0},{1})", row, col)));
this.contextMenu1.Show(c, pt);
}
}

(I have taken it from the sample as explained above)

or if you can modify that sample for GCC, it will be great.

Thanks

Administrator [Syncfusion]
Replied On March 15, 2007 09:11 PM UTC

Hi Dinesh,

Thank you for being patience.

Please refer to the following modified code snippet to have context menu on GridGroupingControl. Kindly try it and let us know if you need any further assistance.
>>>>>>>>>>>>>>>Code Snippet<<<<<<<<<<<<<<
//this.gridGroupingControl1.TableControl.MouseUp += new MouseEventHandler(TableControl_MouseUp);
void TableControl_MouseUp(object sender, MouseEventArgs e)
{
GridTableControl tableControl = sender as GridTableControl;
if (e.Button == MouseButtons.Right)
{
GridCurrentCell cc = tableControl.CurrentCell;
Point pt = new Point(e.X, e.Y);

Control c;
int row;
int col;
if (tableControl == null)
{
c = cc.Renderer.Control;
row = cc.RowIndex;
col = cc.ColIndex;
}
else
{
c = tableControl;
tableControl.PointToRowCol(pt, out row, out col, -1);

}
this.contextMenu1.MenuItems.Clear();
this.contextMenu1.MenuItems.Add(new MenuItem(string.Format("menuForCell({0},{1})", row, col)));
this.contextMenu1.Show(c, pt);
}
}
>>>>>>>>>>>>>>>Code Snippet<<<<<<<<<<<<<<

Have a nice day.

Best regards,
Madhan

dinesh upreti
Replied On March 16, 2007 09:53 AM UTC

thanks,
It works. But there is another problem. May be its the grid's default behaviour. When i right click on a grid's column, it sorting the column. I dont want the colum to be sorted when column is right clicked. Could you help me on that

Thanks


>Hi,
Which searching for managing contect menues, I stumbled upon this message in you forum

http://www.syncfusion.com/Support/forums/message.aspx?MessageID=5109

The sample reference in very colse to what i am looking for. But the problem is that i am working on grid grouping control which has a very different set of properties.

Can you help in translating the following piece of code to implement in GCC

private void dgRangePlanGrid_MouseUp(object sender, MouseEventArgs e)
{
if(e.Button == MouseButtons.Right)
{
GridCurrentCell cc = this.gridControl1.CurrentCell;
Point pt = new Point(e.X, e.Y);

Control c;
int row;
int col;
GridControlBase grid = sender as GridControlBase;
if(grid == null)
{
c = cc.Renderer.Control;
row = cc.RowIndex;
col = cc.ColIndex;
}
else
{
c = grid;
grid.PointToRowCol(pt, out row, out col, -1);

}
this.contextMenu1.MenuItems.Clear();
this.contextMenu1.MenuItems.Add(new MenuItem(string.Format("menuForCell({0},{1})", row, col)));
this.contextMenu1.Show(c, pt);
}
}

(I have taken it from the sample as explained above)

or if you can modify that sample for GCC, it will be great.

Thanks

Administrator [Syncfusion]
Replied On March 16, 2007 02:20 PM UTC

Hi Dinesh,

You can handle the TableControlQueryAllowSortColumn event of the grid and cancel the sorting for the required columns when the right mouse button is clicked. Please try the following code snippet and let me know if this helps

void gridGroupingControl1_TableControlQueryAllowSortColumn(object sender, GridQueryAllowSortColumnEventArgs e)
{
if (e.CellClickEventArgs.MouseEventArgs.Button == MouseButtons.Right)
{
e.AllowSort = false;
}
}

Best regards,
Haneef

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

;