Home Forums WinForms controls Xceed Grid for WinForms ContextMenuStrip Reply To: ContextMenuStrip

User (Old forums)
Post count: 23064

Well, normally, to display a ContextMenu, you will handle to MouseDown event on the element on which you want to pop up a menu. In the same handler, simply set the CurrentRow (or CurrentCell) property and the SelectedRows collection to the row referenced by the sender.

private void Form1_Load(object sender, System.EventArgs e)
foreach( Cell cell in dataRowTemplate1.Cells )
cell.MouseDown += new MouseEventHandler(cell_MouseDown);

void cell_MouseDown( object sender, MouseEventArgs e )
Cell cell = sender as Cell;
gridControl1.CurrentCell = cell;
gridControl1.SelectedRows.Add( cell.ParentRow );

Point point = ( ( Cell )sender).ClientPointToGrid( new Point( e.X, e.Y ) );
if( e.Button == MouseButtons.Right )
menu.Show( gridControl1, point );

Imported from legacy forums. Posted by André (had 323 views)