getValue return的值会 自动写入单元格,这个需要return一个string 或者int 等spread单元格可以接受的类型。
我看您retrun一个list。不知道您的需求是什么。
你可以参考下 文档中的Demo
- public class mySubEd : Form, FarPoint.Win.Spread.CellType.ISubEditor
- {
- public event EventHandler ValueChanged;
- public event EventHandler CloseUp;
- private TextBox txt = null;
- private Button BtnOk = null;
- private Button BtnCancel = null;
- public mySubEd()
- {
- FormBorderStyle = FormBorderStyle.FixedSingle;
- MaximizeBox = false;
- MinimizeBox = false;
- ControlBox = false;
- txt = new TextBox();
- BtnOk = new Button();
- BtnCancel = new Button();
- txt.Location = new Point(0, 0);
- txt.Size = new Size(110, 200);
- txt.ForeColor = Color.Red;
- BtnOk.Location = new Point(3, 75);
- BtnOk.Size = new Size(50, 25);
- BtnOk.Text = "OK";
- BtnOk.ForeColor = Color.Red;
- BtnCancel.Location = new Point(57, 75);
- BtnCancel.Size = new Size(50, 25);
- BtnCancel.Text = "Cancel";
- BtnCancel.ForeColor = Color.Red;
- Controls.Add(txt);
- Controls.Add(BtnOk);
- Controls.Add(BtnCancel);
- Text = "Editor";
- BtnOk.Click += new EventHandler(OKClicked);
- BtnCancel.Click += new EventHandler(CancelClicked);
- txt.TextChanged += new EventHandler(txtTextChanged);
- }
- private void OKClicked(object sender, EventArgs e)
- {
- if (ValueChanged != null)
- ValueChanged(this, EventArgs.Empty);
- if (CloseUp != null)
- CloseUp(this, EventArgs.Empty);
- }
- private void CancelClicked(object sender, EventArgs e)
- {
- if (CloseUp != null)
- CloseUp(this, EventArgs.Empty);
- }
- private void txtTextChanged(object sender, EventArgs e)
- {
- Text = txt.Text;
- }
- public Point GetLocation(Rectangle rect)
- {
- Point pt = new Point(0);
- Size sz = GetPreferredSize();
- pt.Y = (Screen.PrimaryScreen.WorkingArea.Height/2) - (sz.Height/2);
- pt.X = (Screen.PrimaryScreen.WorkingArea.Width/2) - (sz.Width/2);
- return pt;
- }
- public Control GetSubEditorControl()
- {
- return this;
- }
- public object GetValue()
- {
- return txt.Text;
- }
- public void SetValue(object value)
- {
- value = txt.Text;
- }
- public Size GetPreferredSize()
- {
- return new Size(115, 130);
- }
- }
- private void Form1Load(object sender, System.EventArgs e)
- {
- FarPoint.Win.Spread.CellType.TextCellType t = new FarPoint.Win.Spread.CellType.TextCellType();
- t.SubEditor = new mySubEd();
- fpSpread1.ActiveSheet.Cells[0, 0].CellType = t;
- }
- private void fpSpread1SubEditorClose(object sender, FarPoint.Win.Spread.SubEditorClosedEventArgs e)
- {
- textBox1.Text = e.SubEditor.ToString();
- }
复制代码
|