Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change in Memo doesn't trigger change event?

Status
Not open for further replies.

BobbaFet

Programmer
Feb 25, 2001
903
NL
Hi all,

I have a button that allows users to delete lines (which represent a single server) from a memo, which holds the serverlist. So 1 server per line.

When the users adds or deletes a server I want it to save which I put in the onChange event.

Now this works fine for when I use
Memo1.Lines.Add(ServerToAdd);

But for some reason the event isn't triggered by calling
Memo1.Lines.Delete(i);

Does anyone know why this is, or am I doing something wrong?



[bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
Great Delphi Websites faq102-5352
 
PS: I'm using Delphi 7 Enterprise

[bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
Great Delphi Websites faq102-5352
 
Did a quick test in delphi 2005 and it turns out that OnChange event of Memo1 is triggered in both cases:
- Adding lines at run time
- Deleting lines at run time

To test this with Delphi 7, I suggest you create a separate project with one form containing one memo and two buttons to test whether memo OnChange event is triggered you add and delete lines at run time.

If it turns out that the events are triggered than you know you have something wrong else where.

Code:
procedure TForm6.Button1Click(Sender: TObject);
begin
Memo1.Lines.Add('hello')
end;

procedure TForm6.Button2Click(Sender: TObject);
begin
  Memo1.Lines.Delete(0);
end;

procedure TForm6.Memo1Change(Sender: TObject);
begin
  ShowMEssage('changed');
end;

I hope it helps
 
Ok, I've figured out what went wrong, I forgot to set a parameter, I was so focussed on the onChange event not firing that I completely missed it :S Sorry

[bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
Great Delphi Websites faq102-5352
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top