copy instance of any control at runtime
Posted on 1997-08-07
i am trying to write a grid where i can put any control on it. that means i have to create an new instance of any control at runtime but with all data that the source control had. the newinstance function does not what i expect.
so i tried it in this way
function CreateControlCopy( tc:TControl ):TControl;
Result := nil;
AStream := TMemoryStream.Create;
Result := TControl(AStream.ReadComponent(NIL));
this function is quiet ok but it losts the parent. that means if i have a combobox for example with items defined i get an error. :(
does anyone know how to solve this problem ?