网站公告列表

  没有公告

加入收藏
设为首页
联系站长
您现在的位置: 网络学院 >> 程序设计 >> Delphi编程 >> 文章正文
  sender 的應用:所有edit共用一個過濾格式            【字体:
sender 的應用:所有edit共用一個過濾格式
作者:佚名    文章来源:不详    点击数:    更新时间:2007-8-1    
正在装载数据……

1. 所有的Edit 都只允許輸入數字,即只可以輸入一次小數點
2. 不想對多達幾十個的Edit 都寫onKeyPress 事件

那你就寫一個,其它的全部在Object Inspector 中指向這一個:
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
var
  IntCompIdx: Integer;
  stText: string;
begin
  if (Ord(Key) = 46) then
 
begin
    IntCompIdx := (Sender as TEdit).ComponentIndex;
    stText := TEdit(Components[IntCompIdx]).Text;
    if Pos('.', stText) > 1 then
      Key := #0;
  end;
end;

如果不覺得難看的話也可以不用變量:
if (Ord(Key) = 46) and
  (Pos('.', TEdit(Components[(Sender as TEdit).ComponentIndex]).Text) > 1)then
  Key := #0;

站内文章搜索 高级搜索
文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
     在delphi中使用xml文档有…
     初探delphi 7 中的插件编…
     delphi 2006(dexter) & …
     获得windows的版本信息。
     “序列号输入助手”源代…
     rs232串口通讯模块
     ado方式下判断数据表是否…
  • page、request、session、ap…

  • Sevrlet 中防止中文乱码策略

  • Ant入门-配置和使用     选…

  • 浅析Spring框架下PropertyPl…

  • SPRING+STRUTS+HIBERNATE登录…

  • 根据sessionid找回session

  • Cookie又见Cookie-使用Html…

  • 一个关于Comparator的使用例…

  • genexus中对字符串的格式补空…

  • SIP简介,第2部分:SIP SERV…

  •   网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    网络学院©2007 www.23book.net
    为您提供web编程,vb编程,vc编程,服务器架设管理,数据库设计等方面的知识 站长:David