回复 1楼cccdl的帖子
在Spread for WinForms 6.0 中可以尝试下面的代码:
- private void Form1_Load(object sender, EventArgs e)
- {
- FarPoint.Win.Spread.CellType.TextCellType tc = new FarPoint.Win.Spread.CellType.TextCellType();
- fpSpread1.ActiveSheet.Columns[0].CellType = tc;
- }
- private void fpSpread1_EditModeOn(object sender, EventArgs e)
- {
- FarPoint.Win.Spread.CellType.GeneralEditor editor = fpSpread1.EditingControl as FarPoint.Win.Spread.CellType.GeneralEditor;
- if (editor != null)
- {
- editor.KeyPress -= new KeyPressEventHandler(editor_KeyPress);
- editor.KeyPress += new KeyPressEventHandler(editor_KeyPress);
- }
- }
- void editor_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (e.KeyChar <'0' || e.KeyChar > '9')
- {
- e.Handled = true;
- }
- }
复制代码 |