Spread for WPF 跨单元格画线
问题描述:在单元格中画线,实现交叉报表功能问题解答:通过 CustomFloatingObject来在单元格中绘制
关键代码:
public override FrameworkElement Content
{
get
{
if (_content == null)
{
Canvas canvas = new Canvas();
SolidColorBrush stroke = new SolidColorBrush(Colors.Black);
Line line1 = new Line();
line1.Stroke = stroke;
line1.StrokeThickness = 1;
line1.X1 = 0;
line1.Y1 = 0;
line1.X2 = _columnWidth;
line1.Y2 = 3 * _rowHeight;
canvas.Children.Add(line1);
Line line2 = new Line();
line2.Stroke = stroke;
line2.StrokeThickness = 1;
line2.X1 = 0;
line2.Y1 = 0;
line2.X2 = 2 * _columnWidth;
line2.Y2 = _rowHeight;
canvas.Children.Add(line2);
Line line3 = new Line();
line3.Stroke = stroke;
line3.StrokeThickness = 1;
line3.X1 = 0;
line3.Y1 = 0;
line3.X2 = 2 * _columnWidth;
line3.Y2 = 3 * _rowHeight;
canvas.Children.Add(line3);
_content = canvas;
}
return _content;
}
}
效果截图:
示例下载:
请问: 这种画线方式在 winfrom 中怎么实现? 在您的帖子已经讨论,使用Shape。如果有问题我们继续再原帖讨论
页:
[1]