Articles in this section
Category / Section

How to get the formatted text of a record in WinForms GridGroupingControl?

1 min read

Formatting text

You can retrieve the formatted text from the record by using the GetFormattedText() method of StyleInfo object. You can get the StyleInfo for particular field of the record by using the Table.GetTableCellStyle() method.

C#

//Hook the event in Form() to get the record's formatted text on cell click
this.gridGroupingControl1.TableControlCellClick +=gridGroupingControl1_TableControlCellClick;
this.gridGroupingControl1.TableDescriptor.Columns[2].Appearance.AnyRecordFieldCell.Format = "0.00";
private void gridGroupingControl1_TableControlCellClick(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellClickEventArgs e)
{
   //Getting the current record
   Record rec = this.gridGroupingControl1.Table.CurrentRecord;
   //Get the StyleInfo of the Particular field in a record.
   GridTableCellStyleInfo style = this.gridGroupingControl1.Table.GetTableCellStyle(rec, "Column");
   //Getting the value of the column field from the record.
   object cellValue = rec.GetValue("Column");
   //Get the formatted text for the cell value.
   string formattedText = style.GetFormattedText(cellValue);
   //Display the formatted text value
   MessageBox.Show(formattedText);
}

VB

'Hook the event in Form() to get the record's formatted text on cell click
Private Me.gridGroupingControl1.TableControlCellClick += AddressOf gridGroupingControl1_TableControlCellClick
Private Me.gridGroupingControl1.TableDescriptor.Columns(2).Appearance.AnyRecordFieldCell.Format = "0.00"
Private Sub gridGroupingControl1_TableControlCellClick(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellClickEventArgs)
   'Getting the current record
   Dim rec As Record = Me.gridGroupingControl1.Table.CurrentRecord
   'Get the StyleInfo of the Particular field in a record.
   Dim style As GridTableCellStyleInfo = Me.gridGroupingControl1.Table.GetTableCellStyle(rec, "Column")
   'Getting the value of the column field from the record.
   Dim cellValue As Object = rec.GetValue("Column")
   'Get the formatted text for the cell value.
   Dim formattedText As String = style.GetFormattedText(cellValue)
   'Display the formatted text value
   MessageBox.Show(formattedText)
End Sub

The following screenshot illustrates the output.

Showing formatted text for the record

Figure 1: Showing formatted text for the record

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