c# – 如何在DataGridViewCell中设置字符串的方向?
发布时间:2020-12-16 01:41:21 所属栏目:百科 来源:网络整理
导读:如何在DataGridViewColumn中为特定DataGridViewCell设置RightToLeft属性? 解决方法 我知道这是一个老问题,但正如其他人所说,DataGridViewCell和DataGridViewColumn没有RightToLeft属性.但是,这个问题有变通方法: 处理 CellPainting 事件并使用 TextFormatF
如何在DataGridViewColumn中为特定DataGridViewCell设置RightToLeft属性?
解决方法
我知道这是一个老问题,但正如其他人所说,DataGridViewCell和DataGridViewColumn没有RightToLeft属性.但是,这个问题有变通方法:
>处理 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; } } (代码来自CodeProject question.) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |