找回密码
 立即注册

QQ登录

只需一步,快速开始

cccdl
中级会员   /  发表于:2012-6-15 17:11  /   查看:4983  /  回复:1
尝试了textCelltype.CharacterSet  = AlphaNumeric…… 发现能入符号,逗号,小数点……
尝试了regularExpressionCellType……发现离开焦点的时候才会进行校验。
尝试了maskCellType……发现是输入东西变成***……

怎么设定才能只键入a-zA-Z0-9?

向各位大神求助一下,多谢~

1 个回复

倒序浏览
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-6-15 17:54:00
沙发
回复 1楼cccdl的帖子

在Spread for WinForms 6.0 中可以尝试下面的代码:
  1.         private void Form1_Load(object sender, EventArgs e)
  2.         {
  3.             FarPoint.Win.Spread.CellType.TextCellType tc = new FarPoint.Win.Spread.CellType.TextCellType();

  4.             fpSpread1.ActiveSheet.Columns[0].CellType = tc;
  5.         }

  6.         private void fpSpread1_EditModeOn(object sender, EventArgs e)
  7.         {
  8.             FarPoint.Win.Spread.CellType.GeneralEditor editor = fpSpread1.EditingControl as FarPoint.Win.Spread.CellType.GeneralEditor;
  9.             if (editor != null)
  10.             {
  11.                 editor.KeyPress -= new KeyPressEventHandler(editor_KeyPress);
  12.                 editor.KeyPress += new KeyPressEventHandler(editor_KeyPress);
  13.             }
  14.         }

  15.         void editor_KeyPress(object sender, KeyPressEventArgs e)
  16.         {
  17.             if (e.KeyChar <'0' || e.KeyChar > '9')
  18.             {
  19.                 e.Handled = true;

  20.             }
  21.         }
复制代码
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部