Spread选择器之探索

Spread控件,系统默认提供的了2种选择器,分别通过配置属性即可实现。同时,我们也可自定义实现选择器。<a href="http://www.grapecity.com.cn/image.ashx?picture=Spread_Selection.gif"><img title="Spread_Selection" style="display: inline" alt="Spread_Selection" src="http://www.grapecity.com.cn/image.ashx?picture=Spread_Selection.gif" width="407" height="500" /></a>

发布于 2013/12/10 00:00

SpreadJS

Spread控件,系统默认提供的了2种选择器,分别通过配置属性即可实现。同时,我们也可自定义实现选择器。

Spread_Selection

  • 系统选择器:
  1: this.fpSpread1.SelectionRenderer = new FarPoint.Win.Spread.DefaultSelectionRenderer();

 

  • 系统渐变选择器
  1: FarPoint.Win.Spread.GradientSelectionRenderer gsr = new FarPoint.Win.Spread.GradientSelectionRenderer();
  2: gsr.Color1 = Color.Green;
  3: gsr.Color2 = Color.LightGreen;
  4: gsr.LinearGradientMode = System.Drawing.Drawing2D.LinearGradientMode.Vertical;
  5: gsr.Opacity = 100;
  6: this.fpSpread1.SelectionRenderer = gsr;

 

  • 系统选择器,修改颜色
  1: fpSpread1.ActiveSheet.SelectionStyle = FarPoint.Win.Spread.SelectionStyles.SelectionColors;
  2: fpSpread1.ActiveSheet.SelectionPolicy = FarPoint.Win.Spread.Model.SelectionPolicy.Range;
  3: fpSpread1.ActiveSheet.SelectionUnit = FarPoint.Win.Spread.Model.SelectionUnit.Cell;
  4: fpSpread1.ActiveSheet.SelectionBackColor = Color.Yellow;
  5: fpSpread1.ActiveSheet.SelectionForeColor = Color.Green;

 

  • 自定义选择器--渐变色
  1:                     
  2: fpSpread1.ActiveSheet.SelectionStyle = FarPoint.Win.Spread.SelectionStyles.SelectionRenderer;
  3: SelectionRenderer_GradientSelection grd = new SelectionRenderer_GradientSelection(Color.Red, Color.PowderBlue, System.Drawing.Drawing2D.LinearGradientMode.Horizontal, 80);
  4: this.fpSpread1.SelectionRenderer = grd;  
  5:                  
  6: public class SelectionRenderer_GradientSelection : FarPoint.Win.Spread.GradientSelectionRenderer
  7:     {
  8: 
  9:         private Color clr1;
 10: 
 11:         private Color clr2;
 12: 
 13:         private System.Drawing.Drawing2D.LinearGradientMode gradMode;
 14: 
 15:         private int op;
 16: 
 17:         public SelectionRenderer_GradientSelection(Color color1, Color color2, System.Drawing.Drawing2D.LinearGradientMode mode, int opacity) :
 18: 
 19:             base(Color.Beige, Color.Blue, System.Drawing.Drawing2D.LinearGradientMode.ForwardDiagonal, 220)
 20:         {
 21:             clr1 = color1;
 22:             clr2 = color2;
 23:             gradMode = mode;
 24:             op = opacity;
 25:         }
 26: 
 27:         public new void PaintSelection(Graphics g, int x, int y, int width, int height)
 28:         {
 29:             if (((width > 0)
 30:                         && (height < 0)))
 31:             {
 32:                 Color c1 = Color.FromArgb(op, clr1.R, clr1.G, clr1.B);
 33:                 Color c2 = Color.FromArgb(op, clr2.R, clr2.G, clr2.B);
 34:                 LinearGradientBrush selectionBrush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(x, y, width, height), c1,
 35:     c2, gradMode);
 36:                 g.FillRectangle(selectionBrush, x, y, width, height);
 37:                 selectionBrush.Dispose();
 38:             }
 39:         }
 40:     }

SpreadJS | 下载试用

纯前端表格控件SpreadJS,兼容 450 种以上的 Excel 公式,具备“高性能、跨平台、与 Excel 高度兼容”的产品特性,备受华为、苏宁易购、天弘基金等行业龙头企业的青睐,并被中国软件行业协会认定为“中国优秀软件产品”。SpreadJS 可为用户提供类 Excel 的功能,满足表格文档协同编辑、 数据填报、 类 Excel 报表设计等业务场景需求,极大的降低企业研发成本和项目交付风险。

如下资源列表,可以为您评估产品提供帮助:

相关产品
推荐相关案例
推荐相关资源
关注微信
葡萄城社区二维码

关注“葡萄城社区”

活字格低代码二维码

关注“活字格低代码”

想了解更多信息,请联系我们, 随时掌握技术资源和产品动态