2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
Customize the group captionBy default, the grouped columns cell value will be displayed without any formatting in GroupCaptionRow. Solution To change the GroupCaptionText, use QueryCellStyleInfo event to change the cell value using TableCellIdentity. C# void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e) { if (e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionCell && e.TableCellIdentity.GroupedColumn != null) { GridCaptionRow captionRow = e.TableCellIdentity.DisplayElement as GridCaptionRow; string date = ""; DateTime dt; if (e.Style.Text != null && DateTime.TryParse(e.Style.Text.Substring(e.Style.Text.IndexOf(":") + 1, 8), out dt)) { date = dt.ToString("MMM-yyyy"); } e.Style.CellValue = String.Format("{0}: {1} Items.", date, e.TableCellIdentity.DisplayElement.ParentGroup.GetChildCount()); } }
VB Private Sub gridGroupingControl1_QueryCellStyleInfo(ByVal sender As Object, ByVal e As GridTableCellStyleInfoEventArgs) If e.TableCellIdentity.TableCellType = GridTableCellType.GroupCaptionCell AndAlso e.TableCellIdentity.GroupedColumn IsNot Nothing Then Dim captionRow As GridCaptionRow = TryCast(e.TableCellIdentity.DisplayElement, GridCaptionRow) Dim [date] As String = "" Dim dt As DateTime If e.Style.Text IsNot Nothing AndAlso DateTime.TryParse(e.Style.Text.Substring(e.Style.Text.IndexOf(":") + 1, 8), dt) Then [date] = dt.ToString("MMM-yyyy") End If e.Style.CellValue = [String].Format("{0}: {1} Items.", [date], e.TableCellIdentity.DisplayElement.ParentGroup.GetChildCount()) End If End Sub
ScreenShot: Samples: Reference link: https://help.syncfusion.com/windowsforms/classic/gridgroupingcontrol/grouping#customizing-captiontext |
2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.