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?
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"); } } }
Mike, Thanks for the info. I coded a workaround for the moment by using a timer to trigger my dialog with sufficint time to disable the tick. I'll migrate to your code that appears to be cleaner overall.