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
914
BeforeColPosChanged event problems
posted

Using 10.2 UltraWinGrid: I resolve the Click event to show a dialog when the user clicks on the header row. Unfortunately, when the user drags the column header to resize the column, the grid acts as if the header is being resized (you get the correct sizing mouse cursor and dragging changes the location of the vertical line), but as soon as the mouse button is released, the column remains the original size, my Click handler shows my dialog. I thought I could use the BeforeColPosChanged event to set a flag to keep my handler from processing the Click event. But it turns out that the BeforeColPosChanged event doesn't even get raised in this case. If my handler doesn't show the  dialog the column gets resized as it should. But I can determine that the Click event is received before getting the BeforeColPosChanged event; thus, I can't determine that the header click should be ignored. I would think that one of two things should be: (1) the control should not even raise the Click event when the header column is being resized, or (2) the BeforeColPosChanged event should be received before the other event. I actually think it is wrong to raise the Click event if the action being performed is not really a "click" but a "column resize". Comments?

Parents
  • 469350
    Suggested Answer
    Offline posted

    I would do it like this:


            private void ultraGrid1_MouseDown(object sender, MouseEventArgs e)
            {
                UltraGrid grid = (UltraGrid)sender;
                if (e.Button == MouseButtons.Left)
                {
                    // If the mouse click is on an adjustable element, then the user
                    // is resizing something. So bail out.
                    UIElement adjustableUIElement = grid.DisplayLayout.UIElement.AdjustableElementFromPoint(new Point(e.X, e.Y));
                    if (adjustableUIElement != null)
                        return;
                   
                    // Get the column header from the current UIElement containing the mouse.
                    UIElement lastElementEntered = grid.DisplayLayout.UIElement.LastElementEntered;
                    if (lastElementEntered != null)
                    {
                        Infragistics.Win.UltraWinGrid.ColumnHeader columnHeader = lastElementEntered.GetContext(typeof(Infragistics.Win.UltraWinGrid.ColumnHeader)) as Infragistics.Win.UltraWinGrid.ColumnHeader;
                        if (columnHeader != null)
                            MessageBox.Show("Header Clicked");
                    }
                }
            }

Reply Children