sender 的應用:所有edit共用一個過濾格式
来源:百度文库 编辑:神马文学网 时间:2024/04/27 00:26:46
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;
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;
sender 的應用:所有edit共用一個過濾格式
sender 的應用:所有edit共用一個過濾格式
Delphi中Self和Sender的区别
Delphi中Self和Sender的区别
Cool edit pro2.0的使用
共用一个机顶盒的方法
Cool Edit Pro 2.0使用指南 - 王志勇的Blog
Delphi中Self和Sender的区别_静静地陪你走了好远好远
Delphi 中Sender对象
用格式人生最实在的大实话
用RAW格式拍摄的好处
多台电视共用一个的方法
台电视共用一个机顶盒的方法
word用格式刷多次复制格式
word用格式刷多次复制格式
规范的参考文献格式
开题报告的格式
磁盘格式的问题
中国手机号码的格式
个人工作总结的格式
函的格式
公文的格式
条据的格式
公文的格式