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
Hello,
As far as I understand in your scenario you need to get cell value when the user right click on it. To do this you could handle OnMouseDown event of the UltraGrid, and if user is clicked on the cell to get this cell value. You could do this if you write the following code in the event like:
if (e.Button == System.Windows.Forms.MouseButtons.Right)
{
UIElement el = ultraGrid1.DisplayLayout.UIElement.ElementFromPoint(Cursor.Position);
UltraGridCell cell = GetCell(el);// Get cell from point coordinates
if (cell != null)//if there is a cell
//write your code in order to display context menu
object value = cell.Value;// get cell vale
cell.Value = value;// set cell value
}
And here is the implementation of GetCell metod:
private UltraGridCell GetCell(UIElement element)
if (element == null || element.Parent == null)
return null;
if (element.Parent is CellUIElement)
return ((CellUIElement)element.Parent).Cell;
else
return GetCell(element.Parent);
And here is some link about using of context menu:
http://msdn.microsoft.com/en-us/library/aa984254%28v=vs.71%29.aspx
http://msdn.microsoft.com/en-us/library/system.windows.forms.contextmenustrip.aspx
let me know if you have any further questions.
Thanks for the post, was exactly what I was looking for.
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
In Hristo's code snippet above, change Cursor.Position to e.Location otherwise your UIElement variable will always come out null.