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
AD
Administrator
Syncfusion Team
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
DU
dinesh upreti
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
AD
Administrator
Syncfusion Team
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