My RightToLeft DataGridView display numbers in Arabic

我们两清 提交于 2021-01-29 20:39:39

问题


I have a DataGridView in Windows Form Application

When I set DataGridView1.RightToLeft = RightToLeft.No the numbers in this DataGridView are displayed in English like this '12345', but When I set it to RightToLeft.Yes the same numbers are displayed in Arabic like this '١٢٣٤٥' and I don't want this, I want numbers always in English

I think this is because my windows language is Arabic so I tried to change Current Culture, but this didn't help and the numbers are still in Arabic

    Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("en-US")
    My.Application.ChangeUICulture("en-US")
    CultureInfo.CurrentUICulture = New CultureInfo("en-US", True)
    CultureInfo.CurrentCulture = New CultureInfo("en-US", True)

So my question is how to make the DataGridView to display numbers always in English regardless of its RightToLeft state and windows language.

Note: I need the DataGridView to be right to left because my application is in Arabic, and I don't want to change windows settings.

For test:

 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    Dim dt As New DataTable
    With dt
        .Columns.Add("cc1", GetType(System.Int64))
        .Columns.Add("cc2", GetType(System.DateTime))
        .Columns.Add("cc3", GetType(System.Int64))
        .Columns.Add("cc4", GetType(System.Int64))
        .Rows.Add(555555, Now, 589, 369)
        .Rows.Add(-6666666, Now, 789, 654)
    End With
    Me.DataGridView1.DataSource = dt
    Me.Label1.Text = "4444"
    Me.TextBox1.Text = "7777"
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click        '

    If Me.DataGridView1.RightToLeft = RightToLeft.No Then
        Me.DataGridView1.RightToLeft = RightToLeft.Yes
        Me.Label1.RightToLeft = RightToLeft.Yes
        Me.TextBox1.RightToLeft = RightToLeft.Yes
    Else
        Me.DataGridView1.RightToLeft = RightToLeft.No
        Me.Label1.RightToLeft = RightToLeft.No
        Me.TextBox1.RightToLeft = RightToLeft.No
    End If
End Sub

来源:https://stackoverflow.com/questions/59360412/my-righttoleft-datagridview-display-numbers-in-arabic

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!