Spread选择器之探索

发布时间:2013/12/10 00:12 发布者:roger.wang

返回博客中心

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:     }

关于葡萄城

赋能开发者!葡萄城是专业的集开发工具、商业智能解决方案、低代码开发平台于一身的软件和服务提供商,为超过 75% 的全球财富 500 强企业提供服务。葡萄城专注控件软件领域30年,希望通过模块化的开发控件、灵活的低代码应用开发平台等一系列开发工具、解决方案和服务,帮助开发者快速响应复杂多变的业务需求,最大程度地发挥开发者的才智和潜能,让开发者的 IT 人生更从容更美好。

了解详情,请访问葡萄城官网