How to write property in the pascal language? lazarus / 13-General ---------------------------------------------------------------------- tpglemur · 2008-10-02 12:51 At the code below, when I set MyText.Text:='Hello World' at the Button1Click, nothing happens. I expected SetMyText to fire. I know if I had a GetMyText procedure, Setting the Text parameter in MyText will call it, but how do I tell the difference between when it's being called. eg MyText.Text:='Hello World' or Edit1.Text:=MyText.Text Code: [Select]   TForm1 = class(TForm)     Button1: TButton;     Edit1: TEdit;     procedure Button1Click(Sender: TObject);     procedure FormCreate(Sender: TObject);     procedure FormDestroy(Sender: TObject);   private     FMyText: TStringList;   protected     procedure SetMyText(Value: TStringList);   public     property MyText: TStringList read FMyText write SetMyText;   end; var   Form1: TForm1; implementation { TForm1 } procedure TForm1.FormCreate(Sender: TObject); begin   FMyText := TStringList.Create; end; procedure TForm1.FormDestroy(Sender: TObject); begin   FMyText.Free; end; procedure TForm1.Button1Click(Sender: TObject); begin   MyText.Text:='Hello World'; end; procedure TForm1.SetMyText(Value: TStringList); begin   If (Value <> nil) then FMyText.Assign(Value);   Edit1.Text:=FMyText.Text; end;   Hope someone can help. ---------------------------------------------------------------------- theo · 2008-10-02 23:07 Why do you expect SetMyText to fire? MyText.Text:='Hello World' is _reading_  FMyText and then setting the property "Text" of this object (TStringList). SetMyText would "fire" if you did this: MyText:=MyOtherStringList; ---------------------------------------------------------------------- tpglemur · 2008-10-03 05:09 Thanks for your reply, but, how then do I detect a text change? I can't expect the user to create a stringlist everytime he wants to change the text. I notice TStringList has an OnChange property, can this somehow be used? ---------------------------------------------------------------------- theo · 2008-10-03 09:25 I have no idea what you are trying to achieve. Why do you need a Stringlist at all? http://www.catb.org/~esr/faqs/smart-questions.html#goal ---------------------------------------------------------------------- Leledumbo · 2008-10-04 08:46 I agree with theo. Seeing your code, String should be enough.