回复 7楼CanYou8的帖子
和之前提问设置表头居中的帖子类似。
http://gcdn.gcpowertools.com.cn/showtopic-20509.html
重写CellFactory的CreateRowHeaderContent方法,然后设置居中即可。
代码参考:- public class MyCellFactory : CellFactory
- {
- // static fields
- static Thickness _thicknessEmpty = new Thickness(0);
- public override void CreateRowHeaderContent(C1FlexGrid grid, Border bdr, CellRange rng)
- {
- // first column contains numbers
- if (rng.Column == 0)
- {
- var tb = new TextBlock();
- tb.HorizontalAlignment = HorizontalAlignment.Center;
- tb.VerticalAlignment = VerticalAlignment.Center;
- tb.Text = string.Format("{0}", rng.Row + 1);
- bdr.Padding = _thicknessEmpty;
- bdr.Child = tb;
- }
- }
- }
复制代码 |