[Lazarus] TListBox.AddItem doesn't exist?

Howard Page-Clark hdpc at talktalk.net
Sun Oct 21 16:57:48 CEST 2012


On 21/10/12 3:25, Timothy Groves wrote:
> 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





More information about the Lazarus mailing list