[Lazarus] How to use data from stringlist in another form.
appjaws
lazarus at appjaws.plus.com
Wed Mar 27 16:07:25 CET 2013
On 27/03/13 08:06, Antonio Fortuny wrote:
> Le 26/03/2013 15:14, appjaws a écrit :
>> I have 2 forms, form 1 calls form 2 on a buttonclick process.
>> Form 2 loads a string list, operations are carried out and the
>> stringlist is saved.
>
> on FormMain:
> ...
> implementation
> uses
> unit2;
>
> procedure TFrmMain.Button1Click(Sender: TObject);
> begin
> if Form1.List.Count = 0 then
> Form1.LoadList;
> // do whatever do to to compare
> end;
> ==============================================
> on second form:
> unit unit2;
> {$mode objfpc}{$H+}
> interface
> uses
> Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs;
> type
> { TForm1 }
> TForm1 = class(TForm)
> procedure FormCreate(Sender: TObject);
> procedure FormDestroy(Sender: TObject);
> private
> { private declarations }
> FList: TStringList;
> public
> { public declarations }
> procedure LoadList;
>
> property List: TStringList read FList;
> end;
>
> var
> Form1: TForm1;
> implementation
> {$R *.lfm}
> { TForm1 }
> procedure TForm1.FormCreate(Sender: TObject);
> begin
> FList := TStringList.Create;
> end;
>
> procedure TForm1.FormDestroy(Sender: TObject);
> begin
> FList.Free
> end;
>
> procedure TForm1.LoadList;
> begin
> FList.LoadFromFile('myfile.txt')
> end;
>
> end.
Thank you Antonio,
works well with no errors.
Paul
--
---This message has been sent using Thunderbird on kubuntu---
More information about the Lazarus
mailing list