更改列的DataGridView的RightToLeft属性 [英] Change the RightToLeft property of DataGridView for a column
本文介绍了更改列的DataGridView的RightToLeft属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
如何更改DataGridView的列而不是整个DataGridView的RightToLeft属性.
即
我希望DataGridView包含两列,一列为RightToLef,另一列为LeftToRight.
找到解决方案:
处理DataGridView.CellPainting事件并添加以下代码,该代码仅绘制单元格并将其与right和rtl标志对齐.
Hi all,
How can I change the RightToLeft property for the column of a DataGridView and not the whole DataGridView.
i.e
I want my DataGridView to contain two columns, one RightToLef and the other one LeftToRight.
Solution found:
Handle the DataGridView.CellPainting event and add the following code, which simply draws the cell and align it to the right and rtl flags.
private void RTLColumnsDGV_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.ColumnIndex == RTLColumnID && e.RowIndex >= 0)
{
e.PaintBackground(e.CellBounds, true);
TextRenderer.DrawText(e.Graphics, e.FormattedValue.ToString(),
e.CellStyle.Font, e.CellBounds, e.CellStyle.ForeColor,
TextFormatFlags.RightToLeft | TextFormatFlags.Right);
e.Handled = true;
}
}
谢谢,
Gabi.
Thanks,
Gabi.
推荐答案
Gabi,
我在这里找到此链接,您可能想尝试他们在这里所做的事情:
http://blogs.msdn.com/b/vsarabic/archive/2009/01/29/datagridview-with-rtl-columns.aspx
http://www.eggheadcafe.com/软件/aspnet/33821200/setting-righttoleft-property-for-columns-in-a-datagridview.aspx
干杯
Manfred
Hi Gabi,
I found this link here you might want to try what they''re doing there:
http://blogs.msdn.com/b/vsarabic/archive/2009/01/29/datagridview-with-rtl-columns.aspx
http://www.eggheadcafe.com/software/aspnet/33821200/setting-righttoleft-property-for-columns-in-a-datagridview.aspx
Cheers
Manfred
您不能-您只能更改控件的RightToLeft属性:DataGridViewColumn不是控件,因此它没有RightToLeft属性.
You can''t - you can only change the RightToLeft property for a control: DataGridViewColumn is not a control, so it does not have a RightToLeft property.
这篇关于更改列的DataGridView的RightToLeft属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文