从右到左数据网格视图单元格

编程入门 行业动态 更新时间:2024-10-10 19:20:14
本文介绍了从右到左数据网格视图单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何将 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; } }

更多推荐

从右到左数据网格视图单元格

本文发布于:2023-11-23 04:16:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1620053.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网格   视图   单元格   数据   右到左

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!