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
1065
Selecting all rows by clicking rowselectorheader
posted

Hello,

in the WinGrid Samples Explorer you have a sample called "Miscellaneous new features in version 5.1".
The row selector header features are also presented there. In this presentation appears a messagebox by clicking the row selector header. Here the user can choose to select all rows. This works fine.
But what if you have one or more childbands and you click one childband's row selector header? How do you know whose row selector header was clicked to select only the rows of this band?

Here is the sample code. What I have to change so that it works for more than one band?

Private Sub UltraGridRowSelectorHeaderStyle_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ultraGridRowSelectorHeaderStyle.Click

Dim mainElem As UIElement = Me.ultraGridRowSelectorHeaderStyle.DisplayLayout.UIElement
Dim mousePos As Point = Me.ultraGridRowSelectorHeaderStyle.PointToClient(Control.MousePosition)
Dim elem As UIElement = mainElem.ElementFromPoint(mousePos)

If Not Nothing Is elem Then
     elem = elem.GetAncestor(GetType(RowSelectorHeaderUIElement))
End If

If Not Nothing Is elem Then
    
Dim result As DialogResult = MessageBox.Show(Me, "Row Selector Header Clicked. Selecting all rows.", "", MessageBoxButtons.OKCancel)

     If Windows.Forms.DialogResult.OK = result Then
          ' Select all rows.
          Me.ultraGridRowSelectorHeaderStyle.Selected.Rows.AddRange( _
          DirectCast(Me.ultraGridRowSelectorHeaderStyle.Rows.All, UltraGridRow()))
     End If
End If

End Sub

 

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    You can get the context from the element to get the appropriate rows collection.

    If Not Nothing Is elem Then
                Dim result As DialogResult = MessageBox.Show(Me, "Row Selector Header Clicked. Selecting all rows.", "", MessageBoxButtons.OKCancel)

                Dim rows As RowsCollection = CType(elem.GetContext(GetType(RowsCollection)), RowsCollection)

                If Windows.Forms.DialogResult.OK = result Then
                    ' Select all rows.
                    Me.ultraGridRowSelectorHeaderStyle.Selected.Rows.AddRange( _
                     DirectCast(rows.All, UltraGridRow()))
                End If

            End If

Children
No Data