递归清空窗体上 所有文本框,下拉框中的文本

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 yeeyee 的 blog

{*
单元说明:      递归清空窗体上 所有文本框,下拉框中的文本。
作者        :     笔名:易  一    英文名:yeeyee
e-mail      :    jane1437@163.com
创建时间:          2005年3月24日
及最后修改时间:
修改人修改时间及:
修改说明:
版权声明:      版权所有,转载请注明本人邮箱,笔名,
                并保证文章的完整性。
*}

//函数单元。
procedure tformcybase.cleartext(acontrol:twincontrol);
var
  i: integer;
begin
  for i := 0 to acontrol.controlcount - 1 do    // iterate
  begin
    //需清空处理控件
    if acontrol.controls[i] is tcustomedit then
    begin
      (acontrol.controls[i] as tcustomedit).text:='';
    end;
    if acontrol.controls[i] is tcustomcombobox then
    begin
      (acontrol.controls[i] as tcustomcombobox).clearselection;
    end;
    //可以 作为 父亲的控件处理事件。
    if acontrol.controls[i] is tcustomcontrol  then
    begin
      cleartext(acontrol.controls[i] as tcustomcontrol);
    end;
  end;
end;

//函数调用

procedure tformcybase.formkeydown(sender: tobject; var key: word;
  shift: tshiftstate);
begin
  // esc 键处理事件。
  if (key = vk_escape)  then
  begin
    cleartext(self);
  end;
end;

本文关键:递归清空窗体上 所有文本框,下拉框中的文本
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top