UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Homegrown multiselect combobox    
 
   
bobdee
post May 29 2006, 11:12 AM
Post #1

UtterAccess Guru
Posts: 877



On a number of forms I don't have room for a multiselect listbox. So, I've simulated a multiselect combobox (not listbox) using the following method.

1) Place a textbox on the form.
2) Immediately to the right of the textbox place a button of similar size to the Access combobox arrow button and with a picture of an arrow on it.
3) Below the textbox place a multiselect listbox that will be displayed and or hidden depending on when the user clicks on the 'arrow' button.

When a user clicks on the 'arrow' button, the multiselect listbox is displayed. The user can select as many entries as desired. When one entry is selected, the textbox shows that entry. If more than one entry is selected, then the phrase 'Multiple Selections Made' appears in the textbox.

This all works fine. But currently the listbox does not disappear after the last selection is made. I have to click on an area outside the listbox (somewhere else on the form) in order to have code execute to set the listbox visible property to no. This is accomplished in the Detail and Form Header On Click events. However, this is not intuitive because a normal combobox closes it's "list box portion" after a user releases the mouse button.

The multiselect property of the listbox that is being made visible and invisible is set to 'Extended'. So multiple selections need to be made by holding down the 'Shift' or 'Ctrl' keys or by dragging the mouse. Seems like I should be able to cause my listbox to disappear by using an event (mouse and keyboard) if the user releases either the shift or ctrl key or releases the mouse button.

I've never been clear on how these events works so any help is greatly appreciated.

Thanks.
Go to the top of the page
 
+
RuralGuy
post May 29 2006, 12:19 PM
Post #2

UtterAccess VIP
Posts: 2,428
From: @ 8300' in the Colorado Rocky Mountains



You can use some of the events you have mentioned but you can *not* set the visible property of the control with the focus to FALSE. First you need to move the focus elsewhere on your form.
Go to the top of the page
 
+
bobdee
post May 29 2006, 12:57 PM
Post #3

UtterAccess Guru
Posts: 877



Thanks for reminding me about that.

But I'm having some problems with these events. For example, if I hold the Ctrl key or shift down and start making selections with the mouse, if I have a MouseUp event that causes the listbox to become invisible, I can't make more than one selection. How do I handle this??

Thank you.
Go to the top of the page
 
+
ace
post May 29 2006, 01:31 PM
Post #4

UtterAccess VIP
Posts: 5,278
From: Upstate NY, USA



How are you assigning the value from the listbox to the textbox?
Seems to me that would be the place to set the listbox's visible
property also.
Go to the top of the page
 
+
bobdee
post May 29 2006, 02:24 PM
Post #5

UtterAccess Guru
Posts: 877



I'm using the AfterUpdate event of the Listbox. But I believe it's getting fired after every change regardless of whether or not the shift or ctrl keys are being held down. When just dragging the mouse, however, it looks like the AfterUpdate event gets fired after the mouse button is released.

So I don't think this will work for setting the listbox visible property.
Go to the top of the page
 
+
ace
post May 29 2006, 06:46 PM
Post #6

UtterAccess VIP
Posts: 5,278
From: Upstate NY, USA



It's a bit of a kludge, but you can use the same method many people
use for roll-over effects with labels and buttons.

Declare a private form level variable
Private ListIsVisible As Boolean


Then in the listbox's mousemove event put:
ListIsVisible = True

And then the Details Mousemove event put:
If Not ListIsVisible Then Exit Sub
Me.lstSimulatedCombo.Visible = False
ListIsVisible = False


All you have to do is make sure there is enough space between the listbox and
other controls so that the mouse cursor will hit the detail section of the form
when it leaves the listbox area. You can also add the Detail Mousemove code to
any controls that may be so close that they prevent the Detail mousemove event
from occuring.
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 19th May 2013 - 12:08 PM