I could only find how to create a ListBoxItem
by clicking on the component -> Items Editor.
How can we create programmatically a ListBoxItem
using Firemonkey
?
Assuming that a ListBoxItem
is an item of an existing TListBox
component named ListBox1
, the item can be added like this:
ListBox1.Items.Add('an item name');
an alternative:
var
id: Integer;
. . .
ListBox1.Items.AddObject('an item name', TObject(id));
EDIT Notice that this approach has to be considered valid only if the underlying list is not sorted.