找回密码
 立即注册

QQ登录

只需一步,快速开始

zhaozimingT

高级会员

38

主题

207

帖子

1284

积分

高级会员

积分
1284
zhaozimingT
高级会员   /  发表于:2016-9-27 11:51  /   查看:3068  /  回复:1


blob305900267.png


GEtValue spread for winform 返回对象
怎么前台单元格怎么获取 对象内容,怎么解析

1 个回复

倒序浏览
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2016-9-27 16:21:13
沙发
getValue return的值会 自动写入单元格,这个需要return一个string 或者int 等spread单元格可以接受的类型。

我看您retrun一个list。不知道您的需求是什么。

你可以参考下 文档中的Demo
  1. public class mySubEd : Form, FarPoint.Win.Spread.CellType.ISubEditor
  2. {
  3. public event EventHandler ValueChanged;
  4. public event EventHandler CloseUp;
  5. private TextBox txt = null;
  6. private Button BtnOk = null;
  7. private Button BtnCancel = null;

  8. public mySubEd()
  9. {
  10. FormBorderStyle = FormBorderStyle.FixedSingle;
  11. MaximizeBox = false;
  12. MinimizeBox = false;
  13. ControlBox = false;
  14. txt = new TextBox();
  15. BtnOk = new Button();
  16. BtnCancel = new Button();
  17. txt.Location = new Point(0, 0);
  18. txt.Size = new Size(110, 200);
  19. txt.ForeColor = Color.Red;
  20. BtnOk.Location = new Point(3, 75);
  21. BtnOk.Size = new Size(50, 25);
  22. BtnOk.Text = "OK";
  23. BtnOk.ForeColor = Color.Red;
  24. BtnCancel.Location = new Point(57, 75);
  25. BtnCancel.Size = new Size(50, 25);
  26. BtnCancel.Text = "Cancel";
  27. BtnCancel.ForeColor = Color.Red;
  28. Controls.Add(txt);
  29. Controls.Add(BtnOk);
  30. Controls.Add(BtnCancel);
  31. Text = "Editor";
  32. BtnOk.Click += new EventHandler(OKClicked);
  33. BtnCancel.Click += new EventHandler(CancelClicked);
  34. txt.TextChanged += new EventHandler(txtTextChanged);
  35. }

  36. private void OKClicked(object sender, EventArgs e)
  37. {
  38. if (ValueChanged != null)
  39. ValueChanged(this, EventArgs.Empty);
  40. if (CloseUp != null)
  41. CloseUp(this, EventArgs.Empty);
  42. }

  43. private void CancelClicked(object sender, EventArgs e)
  44. {
  45. if (CloseUp != null)
  46. CloseUp(this, EventArgs.Empty);
  47. }

  48. private void txtTextChanged(object sender, EventArgs e)
  49. {
  50. Text = txt.Text;
  51. }

  52. public Point GetLocation(Rectangle rect)
  53. {
  54. Point pt = new Point(0);
  55. Size sz = GetPreferredSize();
  56. pt.Y = (Screen.PrimaryScreen.WorkingArea.Height/2) - (sz.Height/2);
  57. pt.X = (Screen.PrimaryScreen.WorkingArea.Width/2) - (sz.Width/2);
  58. return pt;
  59. }
  60. public Control GetSubEditorControl()
  61. {
  62. return this;
  63. }
  64. public object GetValue()
  65. {
  66. return txt.Text;
  67. }
  68. public void SetValue(object value)
  69. {
  70. value = txt.Text;
  71. }
  72. public Size GetPreferredSize()
  73. {
  74. return new Size(115, 130);
  75. }
  76. }

  77. private void Form1Load(object sender, System.EventArgs e)
  78. {
  79. FarPoint.Win.Spread.CellType.TextCellType t = new FarPoint.Win.Spread.CellType.TextCellType();
  80. t.SubEditor = new mySubEd();
  81. fpSpread1.ActiveSheet.Cells[0, 0].CellType = t;
  82. }

  83. private void fpSpread1SubEditorClose(object sender, FarPoint.Win.Spread.SubEditorClosedEventArgs e)
  84. {
  85. textBox1.Text = e.SubEditor.ToString();
  86. }
复制代码





回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部