你好,使用 MaskedEditCellType 数据类型可以实现该功能,请使用以下代码测试:
- FarPoint.Web.Spread.Extender.MaskedEditCellType m = new FarPoint.Web.Spread.Extender.MaskedEditCellType();
- m.Editor.BackColor = System.Drawing.Color.Beige;
- m.Editor.BorderWidth = 0;
- m.ShowEditor = false;
- m.MaskType = AjaxControlToolkit.MaskedEditType.Number;
- m.Mask = "9999.99";
- m.DisplayMoney = AjaxControlToolkit.MaskedEditShowSymbol.None;
- m.ClearMaskOnLostFocus = true;
- m.InputDirection = AjaxControlToolkit.MaskedEditInputDirection.LeftToRight;
- FpSpread1.ActiveSheetView.Cells[0, 0].CellType = m;
复制代码 另外,DoubleCellType 可以实现如果输入非数字信息,弹出错误提示的功能,测试代码:
- FpSpread1.Sheets[0].ColumnCount = 7;
- FpSpread1.Sheets[0].PageSize = 50;
- FpSpread1.Sheets[0].RowCount = 50;
- FarPoint.Web.Spread.DoubleCellType genrl = new FarPoint.Web.Spread.DoubleCellType();
- genrl.ErrorMessage = "You must use numbers!!";
- int i;
- for (i = 0; i <= 49; i++)
- {
- FpSpread1.Sheets[0].Cells[i, 0].CellType = genrl;
- FpSpread1.Sheets[0].Cells[i, 0].Value = 100 + i;
- }
复制代码 |