Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-10

TListBox.AddItem doesn't exist?

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Timothy Groves

So I am trying to add a TListBox to my program. Relevant code is below.

   TfrmFicMake = class(TForm)
     .
     .
     .
     lstVolumeList: TListBox;
     .
     .
     .
   end;
procedure TfrmFicMake.btnAddVolumeClick(Sender: TObject);
var
   index : integer;
begin
   frmCreateVolume.ShowModal;
   lstVolumeList.Clear;
   for index := 0 to (Length (Volumes) - 1) do
       lstVolumeList.AddItem (Volumes [index].VolumeName);
end;

When I try to compile this, I get:

mainform.pas(55,18) Error: identifier idents no member "AddItem"

Now, I am almost certain, based on having perused the documentation, that TListBox contains a method called AddItem. What am I doing wrong?

Reply by email

Howard Page-Clark
to Timothy Groves: So I am trying to add a TListBox to my program. Relevant code is below. TfrmFicMake =…
Timothy Groves wrote 21 lines
So I am trying to add a TListBox to my program. Relevant code is below. TfrmFicMake = class(TForm) . . . lstVolumeList: TListBox; . . . end; procedure TfrmFicMake.btnAddVolumeClick(Sender: TObject); var index : integer; begin frmCreateVolume.ShowModal; lstVolumeList.Clear; for index := 0 to (Length (Volumes) - 1) do lstVolumeList.AddItem (Volumes [index].VolumeName); end;

The AddItem method takes two parameters, a string and an associated TObject. If you only want to use the listbox to store a list of string items use

   lstVolumeList.Items.Add(Volumes[index].VolumeName);

Howard

Reply by email

John Landmesser
to Timothy Groves: So I am trying to add a TListBox to my program. Relevant code is below. TfrmFicMake =…
Timothy Groves wrote 37 lines
So I am trying to add a TListBox to my program. Relevant code is below. TfrmFicMake = class(TForm) . . . lstVolumeList: TListBox; . . . end; procedure TfrmFicMake.btnAddVolumeClick(Sender: TObject); var index : integer; begin frmCreateVolume.ShowModal; lstVolumeList.Clear; for index := 0 to (Length (Volumes) - 1) do lstVolumeList.AddItem (Volumes [index].VolumeName); end; When I try to compile this, I get: mainform.pas(55,18) Error: identifier idents no member "AddItem" Now, I am almost certain, based on having perused the documentation, that TListBox contains a method called AddItem. What am I doing wrong? -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
just
ListBox1.Items.Add('myString)');

Reply by email