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
2349
Get UltraGridCell Location (Point) (winforms)
posted

Sorry -- posted this in the wrong location earlier.  Someone please help, if you can!!

I am having difficulty finding how to access the ultragridcell location or the x,y coordinates of the top, left of the cell in the UltraGrid. Why isn't there a location property on the cell? I found an example for accessing the UI element and used the current mouse location out of desperation, and the element returns null when it's on the cell that I want to return!! Anyone have an example of how to do this or can someone even mention what property it is that I need to look at? 

CODE THAT DOESN'T GET ME WHAT I'M LOOKING FOR:

UltraGrid grid = (UltraGrid)sender;

Infragistics.Win.UIElement elem = grid.DisplayLayout.UIElement.ElementFromPoint(new Point(grid.DisplayLayout.UIElement.CurrentMousePosition.X, grid.DisplayLayout.UIElement.CurrentMousePosition.Y));

 

Parents
  • 469350
    Offline posted

    Hi,

        What exactly are you trying to do here? 

        You starting off by saying that you want to get the location of a cell in the grid. But the code you listed here does exactly the reverse - it gets a cell from a location.

        To get the location of a cell, you would use the GetUIElement method on the cell to get it's UIElement. This may be null if the cell is not currently visible on the screen. If it's not null, you can get the Rect of the UIElement.

        To get a cell from a location, you can use the code you have here. Except I'm not sure why you are using CurrentMousePosition. This might be a problem if those coordinates are not in the right system. ElementFromPoint takes client coords, not screen coords. If you want to get a cell from a point, I recommend checking out the Infraistics KB. There are lots of articles on how to do this sort of thing.

         Knowledge Base Results - ElementFromPoint

         HOWTO:UltraWinGrid Mouse Position and Cell Identification

Reply Children