C# 右至左DatagridviewCell
如何将属性权限插入DatagridviewCell?我试着设置 Alignment属性为“MiddleRight”,但由于我的DatagridviewCell值为C# 右至左DatagridviewCell,c#,right-to-left,datagridviewtextboxcell,C#,Right To Left,Datagridviewtextboxcell,如何将属性权限插入DatagridviewCell?我试着设置 Alignment属性为“MiddleRight”,但由于我的DatagridviewCell值为 阿拉伯语和英语从右到左不按我的要求显示 要正确使用RightToLeft语言,您应该设置CSS样式rtl。例如: private void CustomizeCellsInThirdColumn() { int thirdColumn = 2; DataGridViewColumn column = d
阿拉伯语和英语从右到左不按我的要求显示 要正确使用RightToLeft语言,您应该设置CSS样式rtl。例如:
private void CustomizeCellsInThirdColumn()
{
int thirdColumn = 2;
DataGridViewColumn column =
dataGridView.Columns[thirdColumn];
DataGridViewCell cell = new DataGridViewTextBoxCell();
cell.Style.Direction = "rtl";
column.CellTemplate = cell;
}
有关更多信息,请阅读和
方向:rtl 我找到了一个关于Cell_绘画事件的解决方案,它很有效。代码如下:
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;
}
}