回复 1楼yaoxiaoqiang00的帖子
测试代码如下:
- private void gcSpreadSheet1_EditChange(object sender, GrapeCity.Windows.SpreadSheet.UI.EditCellEventArgs e)
- {
- SpreadView sv = sender as SpreadView;
- TextBox tx = sv.CellEditor as TextBox;
- string cellText = tx.Text;
- if (!bolNum(cellText))
- {
- tx.Text = tx.Text.Substring(0, tx.Text.Length - 1);
- tx.Select(tx.Text.Length, 0);
- }
-
- }
- public bool bolNum(string temp)
- {
- for (int i = 0; i < temp.Length; i++)
- {
- byte tempByte=Convert.ToByte(temp[i]);
- if ((tempByte<48)||(tempByte>57))
- {
- return false;
- }
- }
- return true;
- }
复制代码
代码中只考虑了在文本末尾输入字符的情况,其他情况请楼主完善下。 |