回复 3楼xinren063的帖子
可以通过以下代码测试,包含了斜体、贯穿线、粗体:
- 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; }
- }
复制代码 |