Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
639
Get Data from UltraWinGrid when right click ContectMenu
posted

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

Parents
  • 48586
    Verified Answer
    posted

    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.

Reply Children
No Data