)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to display the Arabic number digits in WinForms GridControl when the culture is Arabic?

Platform: WinForms |
Control: GridControl |
Published Date: February 24, 2015 |
Last Revised Date: December 19, 2019
Tags: localization

Setting the arabic number digits in grid cell

By default, the native number digits of a particular culture language are not displayed in Grid since text is displayed using GridStaticCellRenderer. To reproduce the native number display in Grid, follow the given steps.

  1. Go to Control Panel.
  2. Select Region
  3. Change the Format as Arabic (Egypt).
  4. Click the Additional Settings button.
  5. In the Numbers tab, change the Use native digits option as National.
  6. 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

 

Note:

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:

 

Row header numbers and grid cell data are shown in arabic digits

Figure 1: GridControl

 

Row header numbers and grid cell data are shown in arabic digits

Figure 2: GridGroupingControl

Samples:

C# - Displaying_The_Arabic_Number_Digits_in_Grid_CS1269007616.zip

VB - Displaying_The_Arabic_Number_Digits_in_Grid_VB1192759562.zip

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon