找回密码
 立即注册

QQ登录

只需一步,快速开始

cqtk

银牌会员

42

主题

79

帖子

2895

积分

银牌会员

积分
2895

活字格认证

cqtk
银牌会员   /  发表于:2012-5-21 14:42  /   查看:5260  /  回复:5
假设当前有四级大纲,用户在选择大纲级别按钮后,可以改变按钮的显示样式,请问这个功能如何实现呢?

5 个回复

倒序浏览
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-5-21 15:51:00
沙发
Spread中可以修改显示样式,比如通过下面的样式来设置:
  1.     fpSpread1.ActiveSheet.Rows.Count = 11;
  2.     fpSpread1.ActiveSheet.Columns.Count = 6;

  3.     FarPoint.Win.Spread.EnhancedInterfaceRenderer outlinelook = new FarPoint.Win.Spread.EnhancedInterfaceRenderer();
  4.     outlinelook.RangeGroupBackgroundColor = Color.LightGreen;
  5.     outlinelook.RangeGroupButtonBorderColor = Color.Red;
  6.     outlinelook.RangeGroupLineColor = Color.Blue;
  7.     fpSpread1.InterfaceRenderer = outlinelook;

  8.     fpSpread1.ActiveSheet.AddRangeGroup(0, 8, true);
  9.     fpSpread1.ActiveSheet.AddRangeGroup(0, 5, true);
  10.     fpSpread1.ActiveSheet.AddRangeGroup(1, 3, false);
  11.     fpSpread1.ActiveSheet.AddRangeGroup(1, 2, false);
复制代码
回复 使用道具 举报
cqtk
银牌会员   /  发表于:2012-5-22 09:07:00
板凳
这段代码是帮助里面的例子,我要的不是这样的效果,举个例子,比如当前选择第三级大纲,则第三级大纲的按钮显示与其它大纲按键不同的样式
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-5-22 09:29:00
地板

回复 3# cqtk 的帖子

如果以上自定义不能满足你的需求,你可以实现一个自定义的IInterfaceRenderer ,比如下面的代码:
  1.     public class MyEnhancedInterfaceRenderer : FarPoint.Win.Spread.IInterfaceRenderer
  2.     {
  3.         FarPoint.Win.Spread.EnhancedInterfaceRenderer enhR = new FarPoint.Win.Spread.EnhancedInterfaceRenderer();

  4.         #region IInterfaceRenderer Members

  5.         public void PaintButton(System.Drawing.Graphics g, int x, int y, int width, int height, FarPoint.Win.Spread.TabStripButton button, bool mouseOver, bool pressed, bool isLeftToRight, bool enabled)
  6.         {
  7.             enhR.PaintButton(g, x, y, width, height, button, mouseOver, pressed, isLeftToRight, enabled);
  8.         }

  9.         public void PaintGrayArea(System.Drawing.Graphics g, int x, int y, int width, int height)
  10.         {
  11.             g.DrawString("", new Font("Arial", 14, FontStyle.Bold), Brushes.Red, 300, 50);
  12.         }

  13.         public void PaintRangeGroupArea(System.Drawing.Graphics g, int x, int y, int width, int height)
  14.         {
  15.             enhR.PaintRangeGroupArea(g, x, y, width, height);
  16.         }

  17.         public void PaintRangeGroupButton(System.Drawing.Graphics g, int x, int y, int width, int height, FarPoint.Win.Spread.GroupState groupState, bool rowGroup, bool isLeftToRight)
  18.         {           
  19.             // 在这里实现自定义Button的逻辑
  20.             //enhR.PaintRangeGroupButton(g, x, y, width, height, groupState, rowGroup, isLeftToRight);
  21.         }

  22.         public void PaintRangeGroupLevelBox(System.Drawing.Graphics g, int x, int y, int width, int height, int groupLevel, bool rowGroup, bool isLeftToRight)
  23.         {
  24.             enhR.PaintRangeGroupLevelBox(g, x, y, width, height, groupLevel, rowGroup, isLeftToRight);
  25.         }

  26.         public void PaintRangeGroupLine(System.Drawing.Graphics g, System.Drawing.Point startPoint, System.Drawing.Point endPoint)
  27.         {
  28.             enhR.PaintRangeGroupLine(g, startPoint, endPoint);
  29.         }

  30.         public void PaintRangeGroupPoint(System.Drawing.Graphics g, System.Drawing.Point point)
  31.         {
  32.             enhR.PaintRangeGroupPoint(g, point);
  33.         }

  34.         public void PaintScrollBox(System.Drawing.Graphics g, int x, int y, int width, int height)
  35.         {
  36.             enhR.PaintScrollBox(g, x, y, width, height);
  37.         }

  38.         public void PaintSheetTab(System.Drawing.Graphics g, int sheet, string text, int x, int y, int width, int height, bool mouseOver, bool focused, FarPoint.Win.Spread.TabStripPlacement placement,
  39.         bool isLeftToRight, bool enabled, System.Drawing.Font font, System.Drawing.Font activeFont)
  40.         {
  41.             enhR.PaintSheetTab(g, sheet, text, x, y, width, height, mouseOver, focused, placement,
  42.             isLeftToRight, enabled, font, activeFont);
  43.         }

  44.         public void PaintSheetTabPartial(System.Drawing.Graphics g, int sheet, string text, int x, int y, int width, int height, bool mouseOver, bool focused, FarPoint.Win.Spread.TabStripPlacement placement,
  45.         bool isLeftToRight, bool enabled, System.Drawing.Font font, System.Drawing.Font activeFont)
  46.         {
  47.             enhR.PaintSheetTabPartial(g, sheet, text, x, y, width, height, mouseOver, focused, placement,
  48.             isLeftToRight, enabled, font, activeFont);
  49.         }

  50.         public void PaintSpecialSheetTab(System.Drawing.Graphics g, int x, int y, int width, int height, bool mouseOver, FarPoint.Win.Spread.TabStripPlacement placementbStrip, bool isLeftToRight, bool enabled, System.Drawing.Font font,
  51.         System.Drawing.Font activeFont)
  52.         {
  53.             enhR.PaintSpecialSheetTab(g, x, y, width, height, mouseOver, placementbStrip, isLeftToRight, enabled, font,
  54.             activeFont);
  55.         }

  56.         public void PaintSplitBar(System.Drawing.Graphics g, int x, int y, int width, int height)
  57.         {
  58.             enhR.PaintSplitBar(g, x, y, width, height);
  59.         }

  60.         public void PaintSplitBarCrossover(System.Drawing.Graphics g, int x, int y, int width, int height)
  61.         {
  62.             enhR.PaintSplitBarCrossover(g, x, y, width, height);
  63.         }

  64.         public void PaintSplitBox(System.Drawing.Graphics g, int x, int y, int width, int height)
  65.         {
  66.             enhR.PaintSplitBox(g, x, y, width, height);
  67.         }

  68.         public void PaintTabStripBackground(System.Drawing.Graphics g, int x, int y, int width, int height, FarPoint.Win.Spread.TabStripPlacement placement)
  69.         {
  70.             enhR.PaintTabStripBackground(g, x, y, width, height, placement);
  71.         }


  72.         #endregion
  73.     }
复制代码
回复 使用道具 举报
cqtk
银牌会员   /  发表于:2012-5-22 11:03:00
5#
逻辑定义好之后要从哪里去调用呢?
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-5-22 11:10:00
6#
在Form_load中添加以下代码:
  1. fpSpread1.InterfaceRenderer = new MyEnhancedInterfaceRenderer ();
复制代码
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部