vb.netinfragisticsultrawingrid

How to get accurate row index from filtered rows of an UltraGrid


I have an UltraGrid. When I click on a Cell, I want it to change a Label's Text to say Record 17 of 2083. Here is my function:

Private Sub grdBackOrders_ClickCell(sender As Object, e As ClickCellEventArgs) Handles grdBackOrders.ClickCell
    Dim rowIndex As Integer = grdBackOrders.ActiveRow.Index + 1
    lblCount.Text = "Record " & rowIndex.ToString() & " of " &
                    CInt(grdBackOrders.DisplayLayout.Rows.VisibleRowCount.ToString()) - 1
End Sub

This works when I am showing all 2083 Records. However, when I filter the rows where it is only showing 30 rows, and I click on the 30th record, my label shows Record 637 of 30. I need it to say Record 30 of 30.


Solution

  • Replace

    Dim rowIndex As Integer = grdBackOrders.ActiveRow.Index + 1
    

    With

    Dim rowIndex As Integer = grdBackOrders.ActiveRow.VisibleIndex