Hi all,Im new to Infragistics, currently I'm trying to add a context menu for my ultraGrid, so when user right-click any data in the grid, and select "show detail" menu, it will send 2 key data into variables then display another pop-up screen with this 2 variables.
Can I request a step by step sample what should I do to get the data when right-click and how should i use mouseDown or mouseMove?
Any guidance/suggestions/examples are greatly appreciated.
Thank you very much,Peace
Thanks for the post, was exactly what I was looking for.
private void toolStripMenuItem_Click(object sender, EventArgs e) {
ToolStripMenuItem t = (ToolStripMenuItem) sender;
ContextMenuStrip s = (ContextMenuStrip)t.Owner;
DataGridView aCell = (DataGridView)s.SourceControl;
MessageBox.show(aCell.CurrentRow.Index.ToString());
}
Thanks alot. I able to the get active row by the right click button.
Now I have to think how should I pass the active row data from MouseDown to subContextMenu_click function. hmmm
Use the code below, and make use of ActiveRow to get the information you need about the row you're right clicking on.
private void ultraGrid1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { UIElement element = ultraGrid1.DisplayLayout.UIElement.ElementFromPoint(e.Location); if (element == null || element.Parent == null) return; Infragistics.Shared.ISelectableItem theitem = element.SelectableItem; if (theitem is UltraGridCell) { ultraGrid1.ActiveRow = ((UltraGridCell)theitem).Row; //Now you can access what ever cell values you need through ActiveRow. //And you can put your context menu showing code here. } } }
Hi Hristo,
Thanks for your guide.
If I only want to get the active row number when I do the right-click action, is that need to use movedown function too? How should I code to grap the row number and index number by a right-click?
Thank you very much.
Warm regards,
Peace