I'm using this code to add an item to a listbox, but I can't figure out how to dynamically resize the height of the item to fit the text:
procedure TmForm.AddItemBtnClick(Sender: TObject);
var
Item: TListBoxItem;
begin
Item := TListBoxItem.Create(nil);
Item.Parent := SomeListBox;
Item.StyleLookup := 'listboxitemstyle';
Item.Text :=
'Pe cararea lunga scurta se ducea un om venind, si-n tacerea lui ' +
'profunda se auzea borborosind. Cantr-o noapte intunecoasa soarel' +
'e lucea pe cer, iara eu cu barca in casa ma plimbam ca un boier.';
Item.WordWrap := true;
Item.StyledSettings := [TStyledSetting.ssFamily] + [TStyledSetting.ssStyle] + [TStyledSetting.ssFontColor];
Item.Font.Size := 14;
end;
I tried using the code from this example (modified for TListBoxItem), but it didn't work.
Edit: The height of the ListBoxItem can be set by just adding Item.Height := 100;
at the end of the code above, but I need to know the height of text to decide what size the ListBoxItem needs to be, so to clarify my question, how do I get the height of the text in the list box item?