Articles in this section
Category / Section

How to customize the column name in GroupDropArea of WinForms GridGroupingControl ?

3 mins read

Column customization


The column name in 
GroupDropArea can be customized by using PrepareViewStyleInfo and QueryColWidth events of GridGroupDropArea.


C#

void Model_QueryColWidth(object sender, Syncfusion.Windows.Forms.Grid.GridRowColSizeEventArgs e)
{
      GridGroupDropAreaModel grid = sender as GridGroupDropAreaModel;
      if (grid.Model[2, e.Index].CellValue != null && grid.Model[2, e.Index].CellValue.ToString().Contains("\n"))
      {
          GridStyleInfo style = grid.Model[2, e.Index];
          e.Size = this.SetTextWidth(style.Text, style.GdipFont) + 20;
          e.Handled = true;
      }
}

//Customize the column name in GropuDropArea.
void GridGroupDropArea_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
   if (e.Style.CellValue.ToString().Contains("\n"))
   {
      e.Style.Text = e.Style.CellValue.ToString().Replace("\n", " ");
   }
}

//Customize the column name in GroupCaptionCell.
void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
   if (e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionCell)
   {
      //To change the group caption text.
      e.Style.Text = e.Style.Text.Replace("\n", " ");
   }
}
VB
Private Sub Model_QueryColWidth(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridRowColSizeEventArgs)
    Dim grid As GridGroupDropAreaModel = TryCast(sender, GridGroupDropAreaModel)
    If grid.Model(2, e.Index).CellValue IsNot Nothing AndAlso grid.Model(2, e.Index).CellValue.ToString().Contains(Constants.vbLf) Then
        Dim style As GridStyleInfo = grid.Model(2, e.Index)
        e.Size = Me.SetTextWidth(style.Text, style.GdipFont) + 20
        e.Handled = True
    End If
End Sub

'Customize the column name in GropuDropArea.
Private Sub GridGroupDropArea_PrepareViewStyleInfo(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs)
   If e.Style.CellValue.ToString().Contains(Constants.vbLf) Then
   e.Style.Text = e.Style.CellValue.ToString().Replace(Constants.vbLf, " ")
   End If
End Sub

'Customize the column name in GroupCaptionCell.
Private Sub gridGroupingControl1_QueryCellStyleInfo(ByVal sender As Object, ByVal e As GridTableCellStyleInfoEventArgs)
   If e.TableCellIdentity.TableCellType = GridTableCellType.GroupCaptionCell Then
      'To change the group caption text.
      e.Style.Text = e.Style.Text.Replace(Constants.vbLf, " ")
   End If
End Sub

The screenshot below shows the before and after customization of column names in the GroupDropArea.

Before Customization

Before customize the column

















After Customization

After customize the column

 



















Samples
:

C#: Customize_Column Name_CS

VB: Customize_Column Name_VB

 

Conclusion

I hope you enjoyed learning about how to customize the column name in GroupDropArea of WinForms GridGroupingControl.

You can refer to our WinForms GridGroupingControl’s feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms GridGroupingControl documentation to understand how to present and manipulate data.

 

For current customers, you can check out our WinForms components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our WinForms GridGroupingControl and other WinForms components.

 

If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied