Hi I am working with XE6 and I am using a TGridPanelLayout with 4 col and 4 rows. On the first cell I am displaying a Button. What I would like to do is, that when I click on this Button, get that Button to appear in a different cell. But I cannot find how to do it, so far I tried this, but nothing happens.
procedure TForm4.Button1Click(Sender: TObject);
begin
GridMyPannel.ControlCollection.BeginUpdate;
GridMyPannel.ControlCollection.AddControl(Button1, 2, 2);
Button1.Parent := GridMyPannel;
end;
I am really new on Delphi. Could anyone give me an example of how I could do it?


A
TGridPanelhas a ControlCollection property which allows access to theRowandColumnproperties that also appear on yourTButtononce you've placed in inside yourTGridpanel. ATButton(or rather its superclassTControl) does not have aRoworColumnproperty. So we need to get a grip of theTControlItemwrapper theTGridpaneluses.The above code finds the button and changes its
RowandColumnproperty to a random value. Note that you didn't specify whether theTButtonis the only control within theTGridpanel. Is that the case?