将数据网格行从左显示编号到右显示 [英] Numbering datagrid rows from left display to right display

查看:63
本文介绍了将数据网格行从左显示编号到右显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I am working for simple program about Time attendance that connect to Virdi FP devices. There is simple problem which is about numbering row in datagrid so I programmed Arabic application. When numbering datagrid it appears to left and I do not want this. I want it in right format so this is the code I used and the problem in Photo appears

<pre lang="c#">var grid = sender as DataGridView;
 var rowIdx = (e.RowIndex + 1).ToString();

 var leftFormat = new StringFormat()
 {
     Alignment = StringAlignment.Center,
     LineAlignment = StringAlignment.Center
 };

 var headerBounds = new Rectangle(e.RowBounds.Left, e.RowBounds.Top, grid.RowHeadersWidth, e.RowBounds.Height);
 e.Graphics.DrawString(rowIdx, this.Font, SystemBrushes.ControlText, headerBounds, leftFormat);





我尝试过:





What I have tried:

var grid = sender as DataGridView;
 var rowIdx = (e.RowIndex + 1).ToString();

 var leftFormat = new StringFormat()
 {
     Alignment = StringAlignment.Center,
     LineAlignment = StringAlignment.Center
 };

 var headerBounds = new Rectangle(e.RowBounds.Left, e.RowBounds.Top, grid.RowHeadersWidth, e.RowBounds.Height);
 e.Graphics.DrawString(rowIdx, this.Font, SystemBrushes.ControlText, headerBounds, leftFormat);

推荐答案

为什么要强行打开门?



查看 DataGridView Properties(System.Windows.Forms) [ ^ ]。有一个 RightToLeft [< a href =https://msdn.microsoft.com/en-us/library/system.windows.forms.control.righttoleft(v=vs.110).aspx\"target =_ blanktitle =New Window > ^ ]属性:



Why to force doors wide open?

Check out DataGridView Properties (System.Windows.Forms)[^] . There's a RightToLeft[^] property:

引用:

RightToLeft 属性用于从右到左书写语言的国际应用程序,例如希伯来语或阿拉伯语。当此属性设置为 RightToLeft.Yes 时,包含文本的控件元素将从右向左显示。

The RightToLeft property is used for international applications where the language is written from right to left, such as Hebrew or Arabic. When this property is set to RightToLeft.Yes, control elements that include text are displayed from right to left.





这个: Windows窗体DataGridView控件中的列填充模式| Microsoft Docs [ ^ ]可能也很有趣


这篇关于将数据网格行从左显示编号到右显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆