掌握这些技能,是你玩转Spread for WinForms的第一步。
-
如何更改焦点指示器
问题描述:选择单元格时,默认单元格会出现黑色边框来突出单元格选择的状态,如何修改指示器样式。如图所示↓

问题解答:可以通过实现IFocusIndicatorRenderer 接口,手动绘制焦点指示器。
关键代码:
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); } }
效果截图:

-
如何修改选择单元格渲染器的背景色
问题描述:单元格被选择时,背景色会暂时改变,如图蓝色部分所示↓

问题解答:可以通过实现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;
效果截图:

想要获得 Spread for WinForms 更多资源或其他相关下载的朋友,请点这里。
想要购买正版 Spread for WinForms 产品的朋友,请点这里。

标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!