只能对数值操作的TextBox(2)

分类: asp.net技巧   出处:iocblog整理  更新时间:2008-11-11   添加到收藏  

  if(idata.getdatapresent(dataformats.text)) //判断是否是text
  {
  string str = (string)idata.getdata(dataformats.text);//取数据
  if (matchnumber(str))
  {
  base.wndproc (ref m);
  break;
  }
  }
  m.result = (intptr)0;//不可以粘贴
  break;
  default:
  base.wndproc (ref m);
  break;
  }
  }
  private bool matchnumber(string clipboardtext)
  {
  int index=0;
  string strnum = "-0.123456789";
  
  index = clipboardtext.indexof(strnum[0]);
  if (index>=0)
  {
  if (index>0)
  {
  return false;
  }
  index = this.selectionstart;
  if (index>0)(www.iocblog.net 文章来源)
  {
  return false;
  }
  }
  
  index = clipboardtext.indexof(strnum[2]);
  if (index!=-1)
  {
  index = this.text.indexof(strnum[2]);
  if (index!=-1)
  {
  return false;
  }
  }
  
  for(int i=0; i  {
  index = strnum.indexof(clipboardtext[i]);
  if (index <0)
  {
  return false;
  }
  }
  return true;
  }
  }
  }(www.iocblog.net 文章来源)

上一页 [1] [2]


Tag: TextBox



文章整理:iocblog
版权申明:本站文章均来自网络,如有侵权,请联系我们,我们收到后立即删除,谢谢!
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有。