How to display the Arabic number digits in WinForms GridControl when the culture is Arabic?
Setting the arabic number digits in grid cell
By default, the native number digits of a particular culture language are not displayed in WinForms GridControl since text is displayed using GridStaticCellRenderer. To reproduce the native number display in Grid, follow the given steps.
- Go to Control Panel.
- Select Region
- Change the Format as Arabic (Egypt).
- Click the Additional Settings button.
- In the Numbers tab, change the Use native digits option as National.
- Click the Apply button and then click the OK button.
Solution
The native number digits of culture language, that is, Arabic numbers, can be displayed in grid cell by handling the DrawCellDisplayText event and displaying the text using TextRenderer.
C#
//Triggering the DrawCellDisplayText event this.gridControl1.DrawCellDisplayText += gridControl1_DrawCellDisplayText; void gridControl1_DrawCellDisplayText(object sender, Syncfusion.Windows.Forms.Grid.GridDrawCellDisplayTextEventArgs e) { //Canceling the default display text using default cell renderer e.Cancel = true; //Displaying the text with TextRenderer instead of GridStaticCellRenderer TextRenderer.DrawText(e.Graphics, e.DisplayText, gridControl1.Font, e.ClipBounds, e.Style.TextColor); }
VB
'Triggering the DrawCellDisplayText event AddHandler Me.gridControl1.DrawCellDisplayText, AddressOf gridControl1_DrawCellDisplayText Private Sub gridControl1_DrawCellDisplayText(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridDrawCellDisplayTextEventArgs) 'Canceling the default display text using default cell renderer e.Cancel = True 'Displaying the text with TextRenderer instead of GridStaticCellRenderer TextRenderer.DrawText(e.Graphics, e.DisplayText, gridControl1.Font, e.ClipBounds, e.Style.TextColor) End Sub
To display the Arabic native digits in GridGroupingControl, the TableControlDrawCellDisplayText event can be handled.
C#
//Triggering the TableControlDrawCellDisplayText event this.gridGroupingControl1.TableControlDrawCellDisplayText += new Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlDrawCellDisplayTextEventHandler(gridGroupingControl1_TableControlDrawCellDisplayText); void gridGroupingControl1_TableControlDrawCellDisplayText(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlDrawCellDisplayTextEventArgs e) { //Canceling the default display text using default cell renderer e.Inner.Cancel = true; //Displaying the text with TextRenderer instead of GridStaticCellRenderer TextRenderer.DrawText(e.Inner.Graphics, e.Inner.DisplayText, e.Inner.Style.Font.GdipFont, e.Inner.ClipBounds, e.Inner.Style.TextColor); }
VB
'Triggering the TableControlDrawCellDisplayText event AddHandler gridGroupingControl1.TableControlDrawCellDisplayText, AddressOf gridGroupingControl1_TableControlDrawCellDisplayText Private Sub gridGroupingControl1_TableControlDrawCellDisplayText(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlDrawCellDisplayTextEventArgs) 'Canceling the default display text using default cell renderer e.Inner.Cancel = True 'Displaying the text with TextRenderer instead of GridStaticCellRenderer TextRenderer.DrawText(e.Inner.Graphics, e.Inner.DisplayText, e.Inner.Style.Font.GdipFont, e.Inner.ClipBounds, e.Inner.Style.TextColor) End Sub
Screenshots:
Figure 1: GridControl
Figure 2: GridGroupingControl
Samples:
C# - Displaying_The_Arabic_Number_Digits_in_Grid_CS1269007616.zip
VB - Displaying_The_Arabic_Number_Digits_in_Grid_VB1192759562.zip
Conclusion
I hope you enjoyed learning how to display the Arabic number digits in WinForms GridControl when the culture is Arabic.
You can refer to our WinForms Grid Control feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms Grid Control example to understand how to create and manipulate data.
For current customers, you can check out our 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 other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!