Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to make a listbox invisible.

Status
Not open for further replies.

EdRev

Programmer
Aug 29, 2000
510
US
I have a listbox that pops-out when user right-click on a text box. The user clicks on the item and the list box disappears. If the user didn't find the item on the list box, i want to give them the option to tab to the next text box, without selecting anything on the listbox. Right now, the list box doesn't disappear until you click on an item. I coded to make it invisible in the listbox_lostfocus, but nothing happenned.

Any help will be greatly appreciated.
 

Hi,

I tried with a form with 2 textboxes (tabindex 0,2) and one listbox (tabindex 1) and :
----------------------------------------------------------
Private Sub List1_LostFocus()
List1.Visible = False
End Sub
----------------------------------------------------------

It seems to work fine. Lets see your code.

Sunaj
 
Thanks for your immediate response,

This is my code.

Private Sub lstRentalLoc_LostFocus()
lstRentalLoc.Visible = False
End Sub

The listbox pops-out when the user right-click on the txtRentalLoc textbox (tabindex 4). I set the tabindex for the listbox (tabindex 122) such that the user can not tab to it. Per my understanding, the listbox will lose focus if the user tab to the next textbox or explicitly go to another textbox via the mouse cursor.

thanks again,
 

Hi,

It sounds a little bit messy, but my guess is that the reason the list never loses it focus is because it never gets the focus.
You could try and give the focus to lstRentalLoc when the user right clicks txtRentalLoc (lstRentalLoc.setfocus). You should however always be carefull when you uses focus to show/hide things. Maybe you can think of a better solution to the problem (a combobox?).

Sunaj
 
Does the listbox ever get focus, or does the focus remain in txtRentalLoc . . . in which case, your lstRentalLoc.Visible = False code should go there. - Jeff Marler B-)
 
thanks again sunaj,

the problem is, I was not giving the listbox the focus. I just made it visible.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top