Q: 如何清除一個視覺化元件上面所有子控制的 Text 屬性
A: 可以使用下面的函式

procedure ClearText(AWinControl: TWinControl);
var
  i: integer;
  pi: PPropInfo;
  AChildControl: TWinControl;
begin
  for i := 0 to AWinControl.ControlCount-1 do
  begin
    if not (AWinControl.Controls[i] is TWinControl) then
      continue;
    AChildControl := TWinControl(AWinControl.Controls[i]);
    if AChildControl.ControlCount > 0 then
      ClearText(AChildControl); // recursive
    pi := GetPropInfo(AChildControl.ClassInfo, 'Text');
    if pi = nil then
      continue;
    SetStrProp(AWinControl.Controls[i], pi, '');
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ClearText(Panel1);
end;


procedure ClearText(AWinControl: TWinControl);
var
  i: integer;
  pi: PPropInfo;
  AChildControl: TWinControl;
begin
  if not (AWinControl is TWinControl) then
    Exit;
  for i := 0 to AWinControl.ControlCount-1 do
  begin
    if not (AWinControl.Controls[i] is TWinControl) then
      continue;
    AChildControl := TWinControl(AWinControl.Controls[i]);
    if AChildControl.ControlCount > 0 then
      ClearText(AChildControl); // recursive
    pi := GetPropInfo(AChildControl.ClassInfo, 'Text');
    if pi = nil then
      continue;
    SetStrProp(AWinControl.Controls[i], pi, '');
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ClearText(Panel1);
end;



// 遞迴清除一個 TWinControl 上所有子控制的 Text 屬性
procedure ClearText(AWinControl: TWinControl);
var
  i: integer;
  pi: PPropInfo;
  AChildControl: TWinControl;
begin
  if not (AWinControl is TWinControl) then
    Exit;
  for i := 0 to AWinControl.ControlCount-1 do
  begin
    if not (AWinControl.Controls[i] is TWinControl) then
      continue;
    AChildControl := TWinControl(AWinControl.Controls[i]);
    if AChildControl.ControlCount > 0 then
      ClearText(AChildControl); // recursive
    pi := GetPropInfo(AChildControl.ClassInfo, 'Text');
    if pi = nil then
      continue;
    SetStrProp(AWinControl.Controls[i], pi, '');
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ClearText(Panel1);
end;


procedure ClearText(AWinControl: TWinControl);
var
  i: integer;
  pi: PPropInfo;
  AChildControl: TWinControl;
begin
  if not (AWinControl is TWinControl) then
    Exit;
  for i := 0 to AWinControl.ControlCount-1 do
  begin
    if not (AWinControl.Controls[i] is TWinControl) then
      continue;
    AChildControl := TWinControl(AWinControl.Controls[i]);
    if AChildControl.ControlCount > 0 then
      ClearText(AChildControl); // recursive
    pi := GetPropInfo(AChildControl.ClassInfo, 'Text');
    if pi = nil then
      continue;
    SetStrProp(AWinControl.Controls[i], pi, '');
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ClearText(Panel1);
end;


procedure ClearText(AWinControl: TWinControl);
var
  i: integer;
  pi: PPropInfo;
  AChildControl: TWinControl;
begin
  if not (AWinControl is TWinControl) then
    Exit;
  for i := 0 to AWinControl.ControlCount-1 do
  begin
    if not (AWinControl.Controls[i] is TWinControl) then
      continue;
    AChildControl := TWinControl(AWinControl.Controls[i]);
    if AChildControl.ControlCount > 0 then
      ClearText(AChildControl); // recursive
    pi := GetPropInfo(AChildControl.ClassInfo, 'Text');
    if pi = nil then
      continue;
    SetStrProp(AWinControl.Controls[i], pi, '');
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ClearText(Panel1);
end;

    Source: geocities.com/huanlin_tsai/faq

               ( geocities.com/huanlin_tsai)