从右到左数据网格视图单元格 [英] RightToLeft DatagridviewCell
本文介绍了从右到左数据网格视图单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将 RightToLeft 属性设置为 DatagridviewCell?我试图设置
How can i sert the property RightToLeft to a DatagridviewCell? I tried to set
对齐属性为MiddleRight",但因为我的 DatagridviewCell 值为
Alignement property to "MiddleRight" but since my DatagridviewCell value is
阿拉伯语和英语从右到左显示不是我想要的.
Arabic and English it is not displayed as i want from right to left.
推荐答案
我通过 Cell_Painting 事件找到了一个解决方案,并且它有效.这是代码:
I found a solution with Cell_Painting event and it works. This is the code:
private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.ColumnIndex == 2 && 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;
}
}
这篇关于从右到左数据网格视图单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文