Delphi 清空某个Form的控件内容,用Tag来判断


本文整理自网络,侵删。

 
//清空某个Form的控件内容,用Tag来判断
procedure TBN.ClearEdit(Frm:TForm;iTag:integer);
var
  ChildCtrl:TComponent;
  icnt:Integer;
begin
  for icnt:= Frm.ComponentCount - 1 downto 0 do
  begin
    ChildCtrl:=Frm.Components[icnt];
    if (ChildCtrl is TEdit) and (ChildCtrl.tag=iTag) then
      TEdit(ChildCtrl).clear;
    if (ChildCtrl is TRzEdit) and (ChildCtrl.tag=iTag) then
      TRzEdit(ChildCtrl).clear;
    if (ChildCtrl is TCombobox) and (ChildCtrl.tag=iTag) then
      TCombobox(ChildCtrl).Text:='';
    if (ChildCtrl is TRzCombobox) and (ChildCtrl.tag=iTag) then
      TRzCombobox(ChildCtrl).Text:='';
    if (ChildCtrl is TRzButtonEdit) and (ChildCtrl.tag=iTag) then
      TRzButtonEdit(ChildCtrl).Text:='';
    if (ChildCtrl is TRzMemo) and (ChildCtrl.tag=iTag) then
      TRzMemo(ChildCtrl).Text:='';
    if (ChildCtrl is TMemo) and (ChildCtrl.tag=iTag) then
      TMemo(ChildCtrl).Text:='';
    if (ChildCtrl is TRadioGroup) and (ChildCtrl.Tag=iTag) then
      TRadioGroup(ChildCtrl).ItemIndex:=0;
    if (ChildCtrl is TRzButtonEdit) and (ChildCtrl.Tag=iTag) then
      TRzButtonEdit(ChildCtrl).Text:='';
    if (ChildCtrl is TDatetimePicker) and (ChildCtrl.Tag=iTag) then
      TDatetimePicker(ChildCtrl).DateTime:=now;
  end;
end;

相关阅读 >>

Delphi xmldocument控件之xml

Delphi 10.3 断点调试相关快捷键

Delphi datasnap 的http 调用返回json

Delphi 10.2 ide界面

Delphi中如何将一整个文件读入内存

Delphi取cpu利用率

Delphi listview高速添加数据

Delphi ascii码表及键盘码表

Delphi 判断两个时间差是否在一个指定范围内

Delphi 每年、月、周、日的开始与结束的时间startofayear … startoftheyear … endofayear … endoftheyear

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...