Articles in this section

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

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.

//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);
}
'Hook the event in Form() to get the record's formatted text on cell click
AddHandler 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)
Access denied
Access denied