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.ClickDim mainElem As UIElement = Me.ultraGridRowSelectorHeaderStyle.DisplayLayout.UIElementDim 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 IfEnd If
End Sub
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