回复 3楼孙增东的帖子
可以通过自定义单元格类型来实现这个功能,参考代码:
- private void Form1_Load(object sender, EventArgs e)
- {
- MyCellType txc = new MyCellType();
- this.fpSpread1.ActiveSheet.DefaultStyle.CellType = txc;
- this.fpSpread1.EditModeOn += fpSpread1_EditModeOn;
- this.fpSpread1.ActiveSheet.Cells[0, 0].Text = "ffd";
- }
- void fpSpread1_EditModeOn(object sender, EventArgs e)
- {
- TextBox gceditor = this.fpSpread1.EditingControl as TextBox;
- gceditor.Select(0, 0);
- gceditor.BackColor = Color.Red;
- }
- }
- public class MyCellType : FarPoint.Win.Spread.CellType.TextCellType
- {
- TextBox test = new TextBox();
- public override Control GetEditorControl(Control parent, FarPoint.Win.Spread.Appearance appearance, float zoomFactor)
- {
- test.BorderStyle = BorderStyle.None;
- return test;
- }
- public override void SetEditorValue(object value)
- {
- test.Text = value.ToString();
- }
- public override object GetEditorValue()
- {
- return test.Text;
- }
- }
复制代码 |