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
108
Get child controls from cursor position
posted

Hi,

We are having an Ultragrid which displays multiple controls in each cell.

Now the problem is that we need to get information displayed on each controls without entering into edit mode of the cell and then show it as tool tip. Entering the edit mode of a cell on hovering degrades the performance.

  - Is there any way we can get current cursor position within a cell?

  - We also need the control to which the cursor is pointing. so, is there any way to implement this?

A sample program is already attached.

Thanks,

TEST%20APP.zip
Parents
No Data
Reply
  • 69832
    Offline posted

    mridulagarg said:
    - Is there any way we can get current cursor position within a cell?

    void ultraGrid_MouseHover(object sender, EventArgs e)
    {
        UltraGrid grid = sender as UltraGrid;
        if ( grid == null )
            return;

        Point clientPos = grid.PointToClient(Cursor.Position);
        UIElement controlElement = grid.DisplayLayout.UIElement;
        UIElement elementAtPoint = controlElement.ElementFromPoint(clientPos);

        while ( elementAtPoint != null )
        {
            CellUIElement cellElement = elementAtPoint as CellUIElement;
            if ( cellElement != null )
            {
                Rectangle rect = cellElement.RectInsideBorders;
                Point relativePos = new Point( clientPos.X - rect.Left, clientPos.Y - rect.Top );
            }

            elementAtPoint = elementAtPoint.Parent;
        }
    }

    mridulagarg said:
    - We also need the control to which the cursor is pointing. so, is there any way to implement this?

    Assuming you have a reference to the user control that contains the controls for which you want to hit test, you can use the Control.GetChildAtPoint method.

Children
No Data