Vb.net 右侧的GridView行数

Vb.net 右侧的GridView行数,vb.net,gridview,Vb.net,Gridview,我试图将行标题中的行号添加到Gridview,我在网上找到了代码,它工作得很好,但我使用的是阿拉伯语,所以我的Gridview是从右到左的,代码将数字添加到左侧,我如何才能使其向右 代码如下: Private Sub RGridView_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles RGridview.RowPostPaint Using b As S

我试图将行标题中的行号添加到
Gridview
,我在网上找到了代码,它工作得很好,但我使用的是阿拉伯语,所以我的
Gridview
是从右到左的,代码将数字添加到左侧,我如何才能使其向右

代码如下:

Private Sub RGridView_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles RGridview.RowPostPaint

    Using b As SolidBrush = New SolidBrush(RGridview.RowHeadersDefaultCellStyle.ForeColor)
        e.Graphics.DrawString(e.RowIndex.ToString(System.Globalization.CultureInfo.CurrentUICulture),
                              RGridview.DefaultCellStyle.Font, b, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4)
    End Using
End Sub

我已将DataGridView属性RightToLeft设置为True。 这样,您可以像这样更改活动:

    Private Sub DataGridView1_RowPostPaint(sender As Object, e As DataGridViewRowPostPaintEventArgs) Handles DataGridView1.RowPostPaint

    Using b As SolidBrush = New SolidBrush(DataGridView1.RowHeadersDefaultCellStyle.ForeColor)
        e.Graphics.DrawString(e.RowIndex.ToString(System.Globalization.CultureInfo.CurrentUICulture),
                          DataGridView1.DefaultCellStyle.Font, b, e.ClipBounds.Width - 30, e.RowBounds.Location.Y + 4)
    End Using
End Sub
获得以下结果:


希望这有帮助

但我如何才能让它从1开始而不是从0开始??感谢您的工作:)将您正在处理的行索引增加1就足够了:(e.RowIndex+1)。ToString(System.Globalization.CultureInfo.CurrentUICulture)如果可以,请告诉我;)