Home Forums WinForms controls Xceed Grid for WinForms Context menu in master/detail Reply To: Context menu in master/detail

User (Old forums)
Post count: 23064

Thanks for your answer, Tommy.

i have the following code:

grid.DataSource = DS;
grid.DataMember = “Tablas”;
DetailGrid detail = new DetailGrid();
detail.HeaderRows.Add( new ColumnManagerRow() );
detail.DataSource = null;
detail.DataMember = “TablaDescripcion”;
grid.DetailGridTemplates.Add( detail );
foreach(Xceed.Grid.DataRow row in grid.DataRows)
foreach(Cell cell in row.Cells)
cell.MouseDown += new MouseEventHandler(grid_MouseDown);
grid.MouseDown += new MouseEventHandler(grid_MouseDown);

and the event handler is

private void grid_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
if (e.Button == MouseButtons.Right)
Xceed.Grid.VisualGridElement element;
Xceed.Grid.Row row;
element = grid.GetVisualGridElementAtPoint(e.X, e.Y);
if (element.GetType().ToString() == “Xceed.Grid.Row”)
row = (Xceed.Grid.Row)element;
if (element.GetType().ToString() == “Xceed.Grid.Cell”)
row = ((Xceed.Grid.Cell)element).ParentRow;
row = null;
if (row != null)
grid.CurrentRow = row; grid.CurrentRow.BringIntoView();
grid.ContextMenu.Show(grid, new System.Drawing.Point(e.X, e.Y));

If i click a row and then right-click in the same row the context menu works, i think by means of the normal processing of the context menu of the grid, because this event is not fired.

In fact, this event is not executed in none of the cells of the grid (i put a debugger stopping point at the beginning of it and the it doesn’t enter).

Thanks for your help.

Imported from legacy forums. Posted by Javier (had 409 views)