如何将属性从右到左设置为 Datagridview 单元格?我尝试设置
Alignment 属性为“MiddleRight”,但由于我的 DatagridviewCell 值为
阿拉伯语和英语没有按照我想要的从右到左显示。
我找到了一个带有 Cell_Painting 事件的解决方案并且它有效。这是代码:
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;
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)