I read a post that addressed which column the user clicked but the answer was in C# and I couldn't convert it to VB. So what i need is to determine which column header the user clicked. In my InitializeLayout I have the HeaderClickAction.SortSingle option set.
When the user clicks to resort the grid by a column i want to trap which column they clicked so I can also sort the related report by the same column.
I understand that i would need to use the grid's mouse Click event & trap the column from there. But how would i go about it.
Any code should be in VB as I don't know C# & it would take me an extremely long time to figure out the VB context for the same code.
Thanks
Gary
Hello Gary,
You could use for example events below:
- MouseDown() - using this event you will get the state before your click
- MouseUp() - using this event you will get the state after your click
Let me know if you have any questions.
Regards
Georgi
Thanks, a quick pass test indicates that the SortIndicator is set sometime after the mouse click event. When I have more time I will play with it to determine when it does get set in the sequence of events. Unless you can suggest which event works best - I'll take any and all advice,
You could use the property columnHeader.Column.SortIndicator
Let me know if you have any questions
Georgi,
Thanks that worked great. But now can I capture which way the sort is going (Ascending or Descending)?
There are different approaches to solve this task. Maybe one possible solution could be:
Private Sub ultraGrid1_MouseClick(sender As Object, e As MouseEventArgs) Dim grid As UltraGrid = DirectCast(sender, UltraGrid) Dim element As UIElement = grid.DisplayLayout.UIElement.LastElementEntered Dim columnHeader As Infragistics.Win.UltraWinGrid.ColumnHeader = TryCast(element.GetContext(GetType(Infragistics.Win.UltraWinGrid.ColumnHeader)), Infragistics.Win.UltraWinGrid.ColumnHeader) If columnHeader IsNot Nothing Then MessageBox.Show("Column click at " + columnHeader.Column.Key) End IfEnd Sub