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

User (Old forums)
Member
Post count: 23064

Tommy,

i have solved the problem using the sender object of the MouseDown event.

after grid.EndInit():

foreach(Xceed.Grid.DataRow row in grid.DataRows)
{
foreach(Cell cell in row.Cells)
cell.MouseDown += new MouseEventHandler(Data_MouseDown);
foreach(Xceed.Grid.DataRow drow in row.DetailGrids[0].DataRows)
{
foreach(Cell dcell in drow.Cells)
dcell.MouseDown += new MouseEventHandler(Data_MouseDown);
}
}

an Data_MouseDown is:

if (e.Button == MouseButtons.Right)
{
Xceed.Grid.Row row = null;
row = ((Xceed.Grid.DataCell)sender).ParentRow;
if (row != null)
{
if (row.CanBeCurrent)
{
grid.CurrentRow = row; grid.CurrentRow.BringIntoView();
grid.SelectedRows.Clear();
grid.CurrentRow.IsSelected = true;
//Assing grid.ContextMenu based on CurrentRow (other code)
}
}
}

I don’t Know how to capture the MouseDown event in the Headers of the master and detail rows, but that is another problem.

Thanks for all.

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