Spread for WinForms是备受欢迎的兼容Microsoft Excel的.NET电子表格控件。其完备的Excel文档支持使得您能够在企业中分享和访问数据信息,内嵌的图表引擎和数据可视化支持让使用者更加轻松的为商务、工程以及科学应用系统中建立丰富高效的信息中心。学习
而使用Spread中文版,还可得到近100万字的中文帮助文档。这些文档不只对产品的每一功能进行了细致的介绍并提供示例代码,还对全部API都提供了中文的说明和参数描述,便于开发人员的学习和使用。我这有Spread for WinForms最新版安装包,有须要的朋友能够体验一下。this
本文整理了四个在使用该控件时可能会遇到的关于边框及网格线的问题及处理方法,如下是详细内容:spa
问题描述:选择单元格时,默认单元格会出现黑色边框来突出单元格选择的状态,如何修改指示器样式。如图所示↓orm
问题解答:能够经过实现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); } }
效果截图:开发
问题描述:单元格被选择时,背景色会暂时改变,如图蓝色部分所示↓get
问题解答:能够经过实现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(); } }
效果如图:
问题描述:如题
问题解答:能够经过SheetView下的HorizontalGridLine和VerticalGridLine来获取或设置网格线样式。
关键代码:
this.fpSpread1.Sheets[0].HorizontalGridLine = new GridLine(GridLineType.None);
效果截图:
问题描述:如何以列为单位设置边框样式。
问题解答: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;
效果截图: