//變更可視元件(TWinControl)擁有者
procedure ChangeOwner(Control: array of TComponent;
newOwner: TWinControl);
var
i: integer;
begin
for i := low(Control) to high(Control) do
begin
newOwner.InsertComponent(Control[i]);
if Control[i] is TWinControl then
TWinControl(Control[i]).Parent := newOwner;
end;
end;
//Example
procedure TForm3.Button3Click(Sender: TObject);
begin
ChangeOwner([cxGrid1, cxGrid1DBTableView1, cxGrid1Level1,
cxGrid1DBTableView1Column1, cxGrid1DBTableView1Column2,
cxGrid1DBTableView1Column3, cxGrid1DBTableView1Column4], Panel1);
end;
沒有留言:
張貼留言