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
950
CellUIElement vs EditorWithTextDisplayTextUIElement
posted

I'm capturing MouseDown event in my UltraGrid and need to figure out when user clicks on a cell in a grid. I was trying to do the following

            UIElement lastElementEntered = grid.DisplayLayout.UIElement.LastElementEntered;
            if (lastElementEntered == null)
                return;

            CellUIElement cellUIElement = lastElementEntered as CellUIElement;
            if (cellUIElement != null)
            {
                <do some stuff here>
            }

but it never gets into the <do some stuff here> area because type of the lastElementEntered is EditorWithTextDisplayTextUIElement and not CellUIElement. Should I just check for EditorWithTextDisplayTextUIElement type or is there a better way?

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    If you want the cell, the easiest thing to do is just to do this:

    UltraGridCell cell = lastElementEntered.GetContext(typeof(UltraGridCell)) as UltraGridCell;

    This will return the cell (or null) regardless of the UIElement you are over.

    If you want to understand why what you have here doesn't work, it's because the CellUIElement contains other elements and those element completely fill the cell element. I recommend that you try the Infragistics UIElementViewer Utility. It will give you a nice display of what element exist, their hierarchy, and positions.

Children
No Data