Alternative of Combobox

Derek

Registered User.
Local time
Today, 12:00
Joined
May 4, 2010
Messages
234
Hi Guys

I am trying to get rid the comboboxes in my project and replace them with something that looks like a textbox but when mousehover event occurs on it then it just expands and shows all the values within it. And when the user selects a value then change that to something that looks like textbox and shows the value within it.

I got the below 6 highlighted steps from CJ_London :

1. create an unbound listbox control - I'll call it lstChoice
2. populate with your list of options
3. move the related label to above the lstChoice- ensure bottom of label is touching top of lstChoice
4. set the height of lstChoice to 0

5. in the lstChoice mousemove event put something like

if lstChoice.height=0 then lstChoice.height=3000 '(whatever height you want in twips - 567 twips=1cm)

6. in the section (header/footer/etc) mousemove event put

if lstChoice.height=3000 then lstChoice.height=0

don't forget to put some code in the lstChoice afterupdate event to take selected action - open form, run a report, whatever.


But now the problem with this is :

a. When the form is loaded then it just displays label and under that just a single line ...(I want the single line to be changed into something so that it looks like a textbox)

b. on the mouse hover event when the list is expanded and we select a particular value from it then it doesn't do anything and I want it to change back to textbox and the value should be showing in it.

Can anyone please help me with "a" and "b" steps ?

Thanks
 
@Derek

a) if you want to see what looks like a textbox, instead of using 0 in the code referenced in steps 5 and 6, use a value - perhaps 250

b) you have to add code for it to do something per the last line of the quote, that code might include

lstChoice.height=0


not sure if it is relevant, but if you display as a textbox, unlike a combo, it will display the first line of the listbox, not what has been selected.

For other responders, this was intended as a menu selector for a form that looks like a web page - see this link

https://www.access-programmers.co.uk/forums/showthread.php?p=1565215#post1565215

If you want it to display the selected item, use a combobox, you can use similar code (per step 5) to show the combo dropdown on a mouse over.
 
1. created an unbound listbox control named lstChoice
2. populated with list of options
3. moved the related label to above the lstChoice- ensured bottom of label is touching top of lstChoice
4. set the height of lstChoice to 284 (0.5cm)

5. in the lstChoice mousemove event put something like

if lstChoice.height=284 then lstChoice.height=3000 '(whatever height you want in twips - 567 twips=1cm)

After following the above steps when the form is loaded the listbox shows 2 arrows (up and down) and shows first value within it. and when i mouse hover on it then it expands and shows all the options.

I don't want to see 2 arrows and the first value in it when the form is loaded.

Can we figure out that bit?
 
@Aman - you are really trying to use my suggestion for something completely different. Scrollbars are a feature of listboxes. There is a complex way of hiding scrollbars involving delving into the windows that make up a listbox using the Hwnd properties for each window, but I don't have the code available and it is used for subforms so may not work for a listbox anyway.

with regard the first value (and scrollbar for that matter) the original suggestion involved setting the listbox height to 0. if you don't want to see the first value, don't populate the rowsource until the mouseover event.
 

Users who are viewing this thread

Back
Top Bottom