回复 1楼q406157290的帖子
这个问题,又尝试了一种解决方案。
重写CellFactory来设置,你可以看看这个和之前提供的方案哪个比较好。
- flexGrid.CellFactory = new MyCellFactory();
- public class MyCellFactory:CellFactory
- {
- public override void CreateCellContent(C1FlexGrid grid, Border bdr, CellRange rng)
- {
- base.CreateCellContent(grid, bdr, rng);
- var r = grid.Rows[rng.Row];
- var child = bdr.Child;
- if (child!=null)
- {
- var text = child as TextBlock;
- if (text!=null && text.Text.Contains("\r\n"))
- {
- text.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
- if (r.Height ==text.DesiredSize.Height+4)
- {
- return;
- }
- text.Margin = new Thickness(2);
- r.Height = Math.Max(text.DesiredSize.Height, r.Height) + 4;
- }
- }
- }
- }
复制代码 |