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
186
Trap Which column user clicked
posted

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

Parents
No Data
Reply
  • 53790
    Verified Answer
    posted

    Hello Gary,

    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 If
    End Sub

    Let me know if you have any questions.

    Regards

Children