首页 > 学院 > 开发设计 > 正文

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

2019-11-18 17:59:45
字体:
来源:转载
供稿:网友

{*
单元说明:      递归清空窗体上 所有文本框,下拉框中的文本。
作者        :     笔名:易  一    英文名: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;


上一篇:修改的一个导出DataSet到xls的单元

下一篇:CRC32生成码表方法实现

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表
学习交流
热门图片

新闻热点

疑难解答

图片精选

网友关注