Appearance of listboxes

H

Hank Youngerman

I have a UserForm with two listboxes on it. Each listbox is populated
with about 4-8 numbers of 2 or 3 digits. Each listbox is wide enough
for about 4 numbers, and high enough for two rows.

When I load the form, the boxes appear with both horizontal and
vertical scroll bars, and I can see two numbers in the boxes, one on
top of the other. The two-digit numbers appear fine, but the
three-digit numbers are aligned such that the right-most number is
partially cut off. For both boxes, the TextAlign property is set to
fmTextAlignLeft. If I change the TextAlign property (to center or
right) the contents disappear, and I have to scroll to the right to see
it.

I populate the boxes with the additem method, specifically:

UserForm1.Radius.AddItem 8
UserForm1.Radius.AddItem 10
UserForm1.Radius.AddItem 100

What appears to be happening is that the control interprets these as
being about 8-10 characters wide. If I widen the listboxes, the scroll
bars go away. But none of the values are greater than 3 digits.

So my first question is, how do I get the listboxes to recognize that
these are just 3-digit numbers, and get it to accomodate a narrow
listbox without scroll bars?

With regard to vertical appearance, I want it to be something like a
dropdown box. What I have now is more like a text window with vertical
scroll bars. Am I just using the wrong kind of control for this?
 
B

Bob Phillips

Width question, set the Columnwidths property.

And yes, it seems you want a Combobox, not a Listbox.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
D

Dave Ramage

Hank,

This is indeed strange behaviour, but seems to be fixed by setting the
ColumnWidth property to something small (e.g. 2).

It does sound like you really want a combobox though, which would only show
the selected value in a single row, or the complete/partial list if the user
clicks the expand arrow. Set the combo box parameter "Style" to
fmStyleDropDownList if you don't want the user to be able to type in values
that aren't in the list.

Cheers,
Dave
 
H

Hank Youngerman

Thanks to both who replied. I have already made the changes in the
ColumnWidth property. I hadn't realized that you could set a property
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top