Along these same lines...
How can I control the header.caption of a groupby row?
I was able to remove the column header that was grouped, but now I am left with ': CATEGORYNMAME (N items).
I want to be able to write my own captions, or at least get ride of the ':' and the number of items in the perenthaces.
This gets what I was looking for:
Private Sub grdFilters_InitializeGroupByRow(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeGroupByRowEventArgs) Handles grdFilters.InitializeGroupByRow If e.Row.Rows.VisibleRowCount > 0 Then Dim firstChildRow As Infragistics.Win.UltraWinGrid.UltraGridRow = e.Row Dim enumeratorForChildRows As Infragistics.Win.UltraWinGrid.RowEnumerator = Nothing 'We can have multiple group by layers. Iterate to the first 'non group-by row and read the data then While firstChildRow.IsGroupByRow enumeratorForChildRows = DirectCast(firstChildRow, Infragistics.Win.UltraWinGrid.UltraGridGroupByRow).Rows.GetEnumerator() enumeratorForChildRows.MoveNext() firstChildRow = enumeratorForChildRows.Current End While If enumeratorForChildRows IsNot Nothing Then 'Find first usable row with data While firstChildRow.Hidden OrElse Not firstChildRow.IsDataRow OrElse firstChildRow.IsFilteredOut If Not enumeratorForChildRows.MoveNext() Then 'No usable rows with data found (should be pretty uncommon situation) 'just return Exit Sub End If firstChildRow = enumeratorForChildRows.Current End While e.Row.Description = CStr(iif(strings.Len(firstChildRow.Cells(e.Row.Column).Text) = 0, _ "Misc.", firstChildRow.Cells(e.Row.Column).Text)) End If End If End Sub
A simpler solution may be to change the GroupByRowDescriptionMask property, which is what the grid uses to determine what to display by default in the group-by row's Description property. This property exists off the Override object, so you can set it for the whole grid from DisplayLayout.Override.GroupByRowDescriptionMask, or change it for an individual band by setting that band's Override.GroupByRowDescriptionMask.
The default value of this property is the following string: "[caption] : [value] ([count] [count,items,item,items])"
If you want to display only the value in the grouped column at a particular level, you can set your GroupByRowDescripitonMask to "[value]".
The primary difference between this and your implementation of the InitializeGroupByRow method is that you're substituting "Misc." in for a blank value. If this is a requirement, then the code you've provided is the way to accomplish this result.
Yes, that is much simpler. Unfortunantly we need the 'Misc.' label for those that are null.
What would be great in the future is to all conditions on the property, like an IIF(strings.len([VALUE]) = 0, "Misc.", [Value])
You could still use the GroupByRowDescriptionMask and handle the InitializeGroupByRow event just for the rows where the value is empty.