<devexpress.spreadsheet>列和行越多,画线越慢

时间:2019-05-14 08:30:30

标签: c# winforms devexpress

将其作为参数并绘制一条与该尺寸对应的线。

列和行越多,画线的速度就越慢。 有什么办法可以改善它?

 private void Linestyle(DevExpress.Spreadsheet.Range rg1)
        {
        rg1.Borders.InsideHorizontalBorders.LineStyle = DevExpress.Spreadsheet.BorderLineStyle.Dotted;
        rg1.Borders.InsideVerticalBorders.LineStyle = DevExpress.Spreadsheet.BorderLineStyle.Dotted;
        rg1.Borders.TopBorder.LineStyle = DevExpress.Spreadsheet.BorderLineStyle.Thick;
        rg1.Borders.LeftBorder.LineStyle = DevExpress.Spreadsheet.BorderLineStyle.Thick;
        rg1.Borders.RightBorder.LineStyle = DevExpress.Spreadsheet.BorderLineStyle.Thick;
        rg1.Borders.BottomBorder.LineStyle = DevExpress.Spreadsheet.BorderLineStyle.Thick;
        rg1.Borders.InsideVerticalBorders.Color = Color.DarkOrange;
        rg1.Borders.InsideHorizontalBorders.Color = Color.DarkOrange;
        rg1.Borders.TopBorder.Color = Color.DarkOrange;
        rg1.Borders.LeftBorder.Color = Color.DarkOrange;
        rg1.Borders.RightBorder.Color = Color.DarkOrange;
        rg1.Borders.BottomBorder.Color = Color.DarkOrange;
        }

2 个答案:

答案 0 :(得分:1)

在设置边框之前使用BeginUpdate(),在设置边框之后使用EndUpdate()。 像这样:

private void Linestyle(DevExpress.Spreadsheet.Range rg1)
{
    rg1.BeginUpdate();
    rg1.Borders.InsideHorizontalBorders.LineStyle = DevExpress.Spreadsheet.BorderLineStyle.Dotted;
    rg1.Borders.InsideVerticalBorders.LineStyle = DevExpress.Spreadsheet.BorderLineStyle.Dotted;
    rg1.Borders.TopBorder.LineStyle = DevExpress.Spreadsheet.BorderLineStyle.Thick;
    rg1.Borders.LeftBorder.LineStyle = DevExpress.Spreadsheet.BorderLineStyle.Thick;
    rg1.Borders.RightBorder.LineStyle = DevExpress.Spreadsheet.BorderLineStyle.Thick;
    rg1.Borders.BottomBorder.LineStyle = DevExpress.Spreadsheet.BorderLineStyle.Thick;
    rg1.Borders.InsideVerticalBorders.Color = Color.DarkOrange;
    rg1.Borders.InsideHorizontalBorders.Color = Color.DarkOrange;
    rg1.Borders.TopBorder.Color = Color.DarkOrange;
    rg1.Borders.LeftBorder.Color = Color.DarkOrange;
    rg1.Borders.RightBorder.Color = Color.DarkOrange;
    rg1.Borders.BottomBorder.Color = Color.DarkOrange;
    rg1.EndUpdate();
}

在10x10范围内的性能:

Without Begin/EndUpdate: ~5430ms
With Begin/EndUpdate: ~17ms

答案 1 :(得分:0)

要更改单元格范围的边界,请为此范围调用Range.BeginUpdateFormatting方法,并使用返回的Formatting对象的Borders属性来访问和修改Borders集合。然后调用Range.EndUpdateFormatting方法以完成修改。

void SetupBorders(DevExpress.Spreadsheet.Range range) {
    Formatting rangeFormatting = range.BeginUpdateFormatting();
    Borders rangeBorders = rangeFormatting.Borders;
    rangeBorders.InsideHorizontalBorders.LineStyle = DevExpress.Spreadsheet.BorderLineStyle.Dotted;
    rangeBorders.InsideVerticalBorders.LineStyle = DevExpress.Spreadsheet.BorderLineStyle.Dotted;
    rangeBorders.TopBorder.LineStyle = DevExpress.Spreadsheet.BorderLineStyle.Thick;
    rangeBorders.LeftBorder.LineStyle = DevExpress.Spreadsheet.BorderLineStyle.Thick;
    rangeBorders.RightBorder.LineStyle = DevExpress.Spreadsheet.BorderLineStyle.Thick;
    rangeBorders.BottomBorder.LineStyle = DevExpress.Spreadsheet.BorderLineStyle.Thick;
    rangeBorders.InsideVerticalBorders.Color = Color.DarkOrange;
    rangeBorders.InsideHorizontalBorders.Color = Color.DarkOrange;
    rangeBorders.TopBorder.Color = Color.DarkOrange;
    rangeBorders.LeftBorder.Color = Color.DarkOrange;
    rangeBorders.RightBorder.Color = Color.DarkOrange;
    rangeBorders.BottomBorder.Color = Color.DarkOrange;
    range.EndUpdateFormatting(rangeFormatting);
}

有关详细信息,请参见How to: Add and Remove Cell Borders