Hi,
I need to handle the UltraGrid.SelectionDrag event. The HeaderClickAction (UltraGrid.DisplayLayout.Override.HeaderClickAction) property is set to SortMulti. The SelectionDrag event is not raised when I start dragging a column. However when I change HeaderClickAction to "Select" the event starts raising.
Why is that? Is there I way the SelectionDrag event is raised when I start dragging a column, when HeaderClickAction event is set to SortMulti?
Thanks,
Vitaly
I can't see any way to do this in MouseUp. Perhaps what you should do is use MouseDown to toggle the sorting, instead of MouseUp.
Then you can check to see if the mouse down is on the adjustable part of the element so you don't sort.
private void ultraGrid1_MouseDown(object sender, MouseEventArgs e) { UltraGrid grid = (UltraGrid)sender; UIElement element = grid.DisplayLayout.UIElement.ElementFromPoint(new Point(e.X, e.Y)); Infragistics.Win.UltraWinGrid.ColumnHeader header = element.GetContext(typeof(Infragistics.Win.UltraWinGrid.ColumnHeader)) as Infragistics.Win.UltraWinGrid.ColumnHeader; if (header != null && element.Adjustable == false) { switch (header.Column.SortIndicator) { case SortIndicator.Ascending: header.Column.SortIndicator = SortIndicator.Descending; break; case SortIndicator.Descending: header.Column.SortIndicator = SortIndicator.Ascending; break; case SortIndicator.None: header.Column.SortIndicator = SortIndicator.Ascending; break; } } }
A year has gone and the issue is back again :)
The original issue was resolved in this way:
Mike Saltzman"] I guess one thing you could do is turn off sorting, and then trap for the MouseUp event of the grid. You could check for a column header at the current position of the mouse and if it's inside a column header, you could toggle the SortIndicator on the column header yourself. That way you could perhaps do both.
I guess one thing you could do is turn off sorting, and then trap for the MouseUp event of the grid. You could check for a column header at the current position of the mouse and if it's inside a column header, you could toggle the SortIndicator on the column header yourself. That way you could perhaps do both.
The problem is that when one column is resized by dragging its right border and the mouse button is released above another column header (right column header border dropped), obviously the MouseUp event arrives above that second column header that is added then to the SortedColumns. These two operations should be separated: the grid should not sort on column resize.
As far as we started with tricky solution, the next tricky step is to determine in the MouseUp event handler that another column is being resized at the same time. Is it possible somehow?
Hi Vitaly,
I don't think these two settings are compatible. When the user mouses down on the header, how would the grid know whether to change the sorting or if a drag operation was about to begin? Even if you started the drag, it would be too late, the column would have been sorted already, which would be strange for your users.
SelectionDrag is tied to selection. If your HeaderClickAction is sorting, then no selection takes place and thus no dragging.
I guess one thing you could do is turn off sorting, and then trap for the MouseUp event of the grid. You could check for a column header at the current position of the mouse and if it's inside a column header, you could toggle the SortIndicator on the column header yourself. That way you could perhaps do both. The only tricky part would be using the UIElements to determine the column header, but this is easy enough once you know how. Check the Infragistics Knowledge Base and do a search for ElementFromPoint. There are lots of articles on this technique.