找回密码
 立即注册

QQ登录

只需一步,快速开始

kdheping_chen

注册会员

1

主题

1

帖子

13

积分

注册会员

积分
13
  • 12

    金币

  • 主题

  • 帖子

最新发帖
kdheping_chen
注册会员   /  发表于:2016-3-9 20:48  /   查看:3358  /  回复:1

一个单元格中能加载自定义控件么?有谁用过,看到存在customType类型,不知道怎么用


1 个回复

倒序浏览
gw0506
超级版主   /  发表于:2016-3-10 12:13:44
沙发
  1. class myCkBox : FarPoint.Win.Spread.CellType.CheckBoxCellType
  2. {
  3. CheckBox ckbx = new CheckBox();

  4. public myCkBox()
  5. {
  6. }
  7. new event EventHandler EditingCanceled;
  8. new event EventHandler EditingStopped;

  9. public override void StartEditing(EventArgs e, bool selectAll, bool autoClipboard)
  10. {
  11.    return;
  12. }
  13. public override void CancelEditing()
  14. {
  15.    EditingCanceled(ckbx, EventArgs.Empty);
  16.    base.FireEditingCanceled();
  17. }
  18. public override bool StopEditing()
  19. {
  20.    if (EditingStopped != null)
  21.    {
  22.       EditingStopped(ckbx, EventArgs.Empty);
  23.       base.FireEditingStopped();
  24.       return true;
  25.    }
  26.    else
  27.    {
  28.       return false;
  29.    }
  30. }

  31. public override bool IsReservedKey(KeyEventArgs e)
  32. {
  33.    return base.IsReservedKey(e);
  34. }
  35. public override object IsReservedLocation(Graphics g, int x, int y, Rectangle r, FarPoint.Win.Spread.Appearance appr, object
  36. value, float zoom)
  37. {
  38.    return base.IsReservedLocation(g, x, y, r, appr, value, zoom);
  39. }
  40. public override Size GetPreferredSize(Graphics g, Size size, FarPoint.Win.Spread.Appearance appr, object value, float zoom)
  41. {
  42.    return base.GetPreferredSize(g, size, appr, value, zoom);
  43. }
  44. public override object Parse(string s)
  45. {
  46.    return base.Parse(s);
  47. }
  48. public override string Format(object o)
  49. {
  50.    return base.Format(o.ToString());
  51. }
  52. public override Control GetEditorControl(FarPoint.Win.Spread.Appearance appearance, float zoomFactor)
  53. {
  54.    return ckbx;
  55. }
  56. public override object GetEditorValue()
  57. {
  58.    return ckbx.CheckState;
  59. }
  60. public override void PaintCell(Graphics g, Rectangle r, FarPoint.Win.Spread.Appearance appr, object value, bool issel, bool
  61. islocked, float zoom)
  62. {
  63.    GetEditorValue();
  64.    if (ckbx.CheckState == CheckState.Checked)
  65.    {
  66.       ControlPaint.DrawCheckBox(g, r.X, r.Y, r.Width - 40, r.Height - 6, ButtonState.Checked);
  67.    }
  68.    else if (ckbx.CheckState == CheckState.Unchecked)
  69.    {
  70.      ControlPaint.DrawCheckBox(g, r.X, r.Y, r.Width - 40, r.Height - 6, ButtonState.Normal);
  71.    }
  72. }
  73. public override void SetEditorValue(object value)
  74. {
  75.    ckbx.CheckState = CheckState.Checked;
  76. }
  77. public override Cursor GetReservedCursor(object o)
  78. {
  79.    return base.GetReservedCursor(o);
  80. }
  81. }

  82. private void menuItem4_Click(object sender, System.EventArgs e)
  83. {
  84.    myCkBox ckbx = new myCkBox();
  85.    fpSpread1.ActiveSheet.Cells[0, 0].CellType = ckbx;
  86. }
复制代码
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部