Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: How to do a variable height TListBox?


This question is answered. Helpful answers available: 1. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Oct 15, 2015 10:59 AM Last Post By: Markus Humm
Markus Humm

Posts: 5,113
Registered: 11/9/03
How to do a variable height TListBox?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 13, 2015 1:55 AM
Hello,

I'm using D10 Seattle and build some Android app. I want to have listboxes where the height is adjusted in a way that always all items of the listbox are shown.

I tried to set the height of the listbox like this:

lb_List.Height := (lb_List.Items.Count * lb_List.ItemHeight) + 5;

But I didn't succeed. The debugger says ItemHeight is 0.
I have to add that this listbox is created dynamically at runtime and the parent is
a ListItem of yet another Listbox which has just been added for this purpose and which
contains other controls as well.

Any hints?

Greetings

Markus
Jeremy North

Posts: 402
Registered: 9/20/99
Re: How to do a variable height TListBox?
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 14, 2015 6:40 PM   in response to: Markus Humm in response to: Markus Humm
Markus Humm wrote:
Hello,

I'm using D10 Seattle and build some Android app. I want to have listboxes where the height is adjusted in a way that always all items of the listbox are shown.

I tried to set the height of the listbox like this:

lb_List.Height := (lb_List.Items.Count * lb_List.ItemHeight) + 5;

But I didn't succeed. The debugger says ItemHeight is 0.
I have to add that this listbox is created dynamically at runtime and the parent is
a ListItem of yet another Listbox which has just been added for this purpose and which
contains other controls as well.

Any hints?

You most likely need to iterate over the items and set the height of those. I think the ItemHeight is only used when the item is created. Use ListItems to access the (TListBoxItem) items in the list.
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: How to do a variable height TListBox?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 15, 2015 10:59 AM   in response to: Jeremy North in response to: Jeremy North
Am 15.10.2015 um 03:40 schrieb Jeremy North:
Markus Humm wrote:
Hello,

I'm using D10 Seattle and build some Android app. I want to have listboxes where the height is adjusted in a way that always all items of the listbox are shown.

I tried to set the height of the listbox like this:

lb_List.Height := (lb_List.Items.Count * lb_List.ItemHeight) + 5;

But I didn't succeed. The debugger says ItemHeight is 0.
I have to add that this listbox is created dynamically at runtime and the parent is
a ListItem of yet another Listbox which has just been added for this purpose and which
contains other controls as well.

Any hints?

You most likely need to iterate over the items and set the height of those. I think the ItemHeight is only used when the item is created. Use ListItems to access the (TListBoxItem) items in the list.

Hello,

thanks for the tip. I have developed a completely different solution by
now, which uses a variable amount of radio buttons and I calculate the
y-coordinate and alter the height of the ListBoxItem they're on so they fit.

Solution has been shown to some users which applauded verbally ;-)

Greetings

Markus
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02