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
785
How to tell when when resizing columns or only allow at the column header?
posted

Two questions:

A) How can I tell if the grid is currently in the process of sizing columns?  I have hooked the Mouse Down event and would like to perform a specific action if the user is Not sizing columns.  Problem is, I can't figure out how to tell if they are selecting a row/cell or sizing.  The cursor changes to a "size" cursor so I know the grid knows.

B) How can I tell the grid to Only allow column sizing using the column headers (as compared to anywhere from within the grid)? DisplayLayout.Override.AllowColSizing does not give the necessary options for restricting to the column headers.

Thanks in advance.

 

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Hi,

    DSSavant said:
    A) How can I tell if the grid is currently in the process of sizing columns?  I have hooked the Mouse Down event and would like to perform a specific action if the user is Not sizing columns.  Problem is, I can't figure out how to tell if they are selecting a row/cell or sizing.  The cursor changes to a "size" cursor so I know the grid knows.

    The grid determines this by using the UIElements and looking for a particular type of element called an AdjustableUIElement. So what you can do is something like this:


            private void ultraGrid1_MouseDown(object sender, MouseEventArgs e)
            {
                UltraGrid grid = (UltraGrid)sender;
                UIElement element = grid.DisplayLayout.UIElement.LastElementEntered;
                if (element != null)
                {
                    UIElement adjustableElement = element.AdjustableElementFromPoint(new Point(e.X, e.Y));
                    if (adjustableElement != null)
                    {
                        // If we get to this point, then it means the mouse is currently over an adjustable
                        // element, so bail out.
                        return;
                    }
                }
            }

     

    But it seems to me that you probably want to determine what the mouse is actually over and only handle certain cases, rather than determining what the mouse is not over and eliminating those.I don't know what you are trying to do in MouseDown, so maybe I am wrong.

    DSSavant said:
    B) How can I tell the grid to Only allow column sizing using the column headers (as compared to anywhere from within the grid)? DisplayLayout.Override.AllowColSizing does not give the necessary options for restricting to the column headers.

    The property you are looking for is on the Override and it's called ColumnSizingArea. There is also a RowSizingArea property.

     

     

Children