使用Spread for WinForms表格控件時你可能會遇到這些問題

Spread for WinForms是備受歡迎的兼容Microsoft Excel的.NET電子表格控件。其完備的Excel文檔支持使得您能夠在企業中分享和訪問數據信息,內嵌的圖表引擎和數據可視化支持讓使用者更加輕鬆的爲商務、工程以及科學應用系統中建立豐富高效的信息中心。學習

而使用Spread中文版,還可得到近100萬字的中文幫助文檔。這些文檔不只對產品的每一功能進行了細緻的介紹並提供示例代碼,還對全部API都提供了中文的說明和參數描述,便於開發人員的學習和使用。我這有Spread for WinForms最新版安裝包,有須要的朋友能夠體驗一下。this

本文整理了四個在使用該控件時可能會遇到的關於邊框及網格線的問題及處理方法,如下是詳細內容:spa

  • 如何更改焦點指示器

問題描述:選擇單元格時,默認單元格會出現黑色邊框來突出單元格選擇的狀態,如何修改指示器樣式。如圖所示↓orm

image149_14.jpg

問題解答:能夠經過實現IFocusIndicatorRenderer 接口,手動繪製焦點指示器。blog

關鍵代碼:接口

public class MyIndicator : FarPoint.Win.Spread.IFocusIndicatorRenderer
    {
public void Paint(System.Drawing.Graphics g, int x, int y, int width, int height, bool left, bool top, bool right, bool bottom)
        {
            SolidBrush r = new SolidBrush(System.Drawing.Color.Red);
            SolidBrush b = new SolidBrush(System.Drawing.Color.Blue);
            SolidBrush gr = new SolidBrush(System.Drawing.Color.DarkGreen);
            g.FillRectangle(r, x, y, 1, height);
            g.FillRectangle(gr, x, y, width, 1);
            g.FillRectangle(r, x + width - 1, y, 1, height);
            g.FillRectangle(b, x, y + height - 1, width, 1);
        }
    }

效果截圖:開發

image149_15.png

詳細操做請查看相關示例瞭解文檔

  • 如何修改選擇單元格渲染器的背景色

問題描述:單元格被選擇時,背景色會暫時改變,如圖藍色部分所示↓get

1.png

問題解答:能夠經過實現ISelectionRenderer接口,手動填充選擇背景色。產品

關鍵代碼:

public class SelectionRenderer : FarPoint.Win.Spread.ISelectionRenderer
    {
        public void PaintSelection(Graphics g, int x, int y, int width, int height)
        {
            SolidBrush selectionBrush = new SolidBrush(Color.FromArgb(100, Color.Green));
            g.FillRectangle(selectionBrush, x, y, width, height);
            selectionBrush.Dispose();
        }
    }

效果如圖:

2.png

詳細操做請查看相關示例瞭解

  • 如何隱藏默認的橫向網格線

問題描述:如題

問題解答:能夠經過SheetView下的HorizontalGridLine和VerticalGridLine來獲取或設置網格線樣式。

關鍵代碼:

 this.fpSpread1.Sheets[0].HorizontalGridLine = new GridLine(GridLineType.None);

效果截圖:

image149_18.jpg

  • 如何設置列邊框顏色

問題描述:如何以列爲單位設置邊框樣式。

問題解答:Spread 提供了LineBorder 和BevelBorder 類用於設置邊框。

關鍵代碼:

FarPoint.Win.LineBorder lineborder = new FarPoint.Win.LineBorder(Color.Green, 2, true, true, true, true);
            fpSpread1.Sheets[0].Columns[0].Border = lineborder;
            fpSpread1.BorderCollapse =  FarPoint.Win.Spread.BorderCollapse.Collapse;

效果截圖:

image149_19.jpg

相關文章
相關標籤/搜索