Make a listbox act similiar to a combo box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

On one of my forms, I would like to display listbox (need to display multiple
fields at all times) which only displays one row of data when it is not
selected. I have figured out how to do some of this, but not all.

I have got/lost focus events that change the height of the list, but if the
lengthened list overlaps another control, it doesn't display properly. I've
tried repainting the controls, but that does not work. I can hide the
control that gets overlapped, but what I would really like to do is make the
overlap work without doing this. Any ideas?

When the user selects one of the items, the cursor moves to the next
control, and the list shrinks to display only the header and one row, but the
row displayed is not necessarily the row that was selected. How do you force
the one row that is visible to display the item that is selected?

I also tried just displaying a single row. This works when the user uses
the cursor keys to scroll thru the list, but when they use the up and down
buttons from the scroll bar, it changes the record that is visible in the
list, but not the selection. Using this technique, is there a way, using the
lost focus, to determine which record is visible in the list?
 
Dale said:
On one of my forms, I would like to display listbox (need to display multiple
fields at all times) which only displays one row of data when it is not
selected. I have figured out how to do some of this, but not all.

I have got/lost focus events that change the height of the list, but if the
lengthened list overlaps another control, it doesn't display properly. I've
tried repainting the controls, but that does not work. I can hide the
control that gets overlapped, but what I would really like to do is make the
overlap work without doing this. Any ideas?

When the user selects one of the items, the cursor moves to the next
control, and the list shrinks to display only the header and one row, but the
row displayed is not necessarily the row that was selected. How do you force
the one row that is visible to display the item that is selected?

I also tried just displaying a single row. This works when the user uses
the cursor keys to scroll thru the list, but when they use the up and down
buttons from the scroll bar, it changes the record that is visible in the
list, but not the selection. Using this technique, is there a way, using the
lost focus, to determine which record is visible in the list?


I can't help you on your trials and tribulations with list
boxes, because I never use them. However, you may want to
consider my standard alternatives.

One is to use text boxes next to the combo box. Set their
control source expression to:
=combobox.Column(2)
to display the data in the combo's third column.

Another is to use a continuous subform instead of a list
box. Forms provide much more control than list boxes, but
they're also more complicated than the above text box
approach.
 
Thanks Marshall, the textbox thing worked really well. I setup the GotFocus
event of the combo to make it wide enough to cover the text boxes, then, in
the lost focus, I set it up to skip over the text boxes, and shrink the
combo back to it's original size. Works like a charm.

Any particular reason you don't like text boxes?

Dale
 
That sounds like a nice approach, Dale.

I usually give the "extra" text boxes a light gray back
color so the users can see that they're not editable. One
other thought, you might (or might not) want to use the
DropDown method in your GotFocus event.

I'm not trying to talk anyone out of using list boxes, I
just prefer the flexibility (especially formatting
properties) of the other ways.

Simulating a multi-select list box with a continuous subform
can be a lot of work though.
 

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

Back
Top