Hi All Hope you are all doing great.
I have created a context menu and have associated it with the grid. But I need selecte which row the user has clicked so that I can do manipulations to that row only.
Can anybody help me in doing this.
Thanks
I do not know is this solution a best one but you can use this approach:
1. Subscribe on MouseClick event of a grid.
grid_.MouseClick += new System.Windows.Forms.MouseEventHandler(this.OnGridMouseClick)
2. In MouseClick handler check whether the pressed button is right one and if so
determine what is the row you have clicked on:
private void OnGridMouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { UIElement element = grid_.DisplayLayout.UIElement.ElementFromPoint(e.Location); if (element != null) { UltraGridRow row = element.GetContext(typeof (UltraGridRow)) as UltraGridRow; if (row != null) { .... // save this row or do what you want. } } } }
Alex