Accessing properties by name
Posted on 2001-06-04
I am trying to access properties by using a text string and am not sure how to go about it, or indeed if it is possible. The sort of thing I am trying to do is as follows:
procedure TForm1.Button1Click(Sender: TObject);
xx : TComponent;
yy : TProperty;
ss : string;
xx := FindComponent('Edit1');//find the component
yy := (xx as xx.ClassType).FindProperty('Text');//type cast the component and find the Text property
yy := 'Test Data'; //write to property
ss := yy; //read from property
I know this is rubbish but it illustrates the sort of thing I am trying to do.
Please illustrate any possible answers with code.