回复 1楼jxlxl的帖子
可以使用CellFactory来实现。
包含斜体、贯穿线和粗体,代码参考:
- public class MyCellFactory : C1.WPF.FlexGrid.CellFactory
- {
- public override void ApplyCellStyles(C1.WPF.FlexGrid.C1FlexGrid grid, C1.WPF.FlexGrid.CellType cellType, C1.WPF.FlexGrid.CellRange rng, Border bdr)
- {
- base.ApplyCellStyles(grid, cellType, rng, bdr);
- if (cellType == C1.WPF.FlexGrid.CellType.Cell)
- {
- var row = grid.Rows[rng.Row].Index;
- var _textblock = bdr.Child as TextBlock;
- if (row % 2 == 0)
- {
- //underline text
- _textblock.FontWeight = FontWeights.Bold;
- _textblock.FontStyle = FontStyles.Italic;
- _textblock.TextDecorations = TextDecorations.Strikethrough;
- }
- else
- {
- //Strikeout text
- bdr.Child = null;
- double width = 0;
- double height = 0;
- if (_textblock != null)
- {
- width = _textblock.ActualWidth;
- height = _textblock.ActualHeight;
- }
- Line _line = new Line();
- _line.Stroke = new SolidColorBrush(Colors.Black);
- _line.StrokeThickness = 1;
- _line.X1 = 0;
- _line.Y1 = (height / 2) + 3;
- _line.X2 = width + 1;
- _line.Y2 = (height / 2) + 3;
- Grid grd = new Grid();
- grd.Children.Add(_line);
- _textblock.FontWeight = FontWeights.Thin;
- _textblock.FontStyle = FontStyles.Italic;
- grd.Children.Add(_textblock);
- bdr.Child = grd;
- }
- }
- }
- }
- public class TestData
- {
- public string Name { get; set; }
- public string Title { get; set; }
- }
复制代码
安装产品后,也可以在如下路径找到CellFactory示例演示:
\Documents\ComponentOne Samples\Studio for WPF\C1.WPF.FlexGrid\CS\UnboundCellFactory |