Listboxes and select items in it

D

droopy928gt

Dear all,

I've got a question on listboxes which I can't find an answer for no
figure it out myself if what I want is at all possible.

I use a textbox in combination with a listbox to find and select items
For the listbox the multiselect property is true and liststyle is se
to options.

What I do is to type in the textbox and depending upon what is typed a
item is selected in the listbox, being its listindex is set BUT NOT it
selected property.

This all works well basically except for the fact that you can't se
which items listindex is set unless you set focus to the listbox. Whe
an items selected property is set though its both highlighted and it
checkbox is set.

The question basically is if its possible to highlight an item in th
listbox without setting its selected property.

OR

If someone knows of a way to show which listbox items listindex i
currently set without the listbox having the focus.

Thanks for any ideas and tips.

Best regards,

Leon v/d Willi
 
G

Guest

Hi,

Is this what you want?

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
ListBox1.Value = TextBox1.Value
MsgBox ListBox1.ListIndex
 
D

droopy928gt

Hi Topper,

Thanks for the tip but this is not what I'm looking for.

I want to stay in the textbox while typing and compare typed text to
entries in the listbox. Positive compares are followed up by setting
the listindex for that listbox value.

The problem lies in seeing which listbox items listindex is set while
it does not have the focus. That's what I'm trying to overcome.

Only when the focus is set to the listbox will the item whose listindex
is set show with a dotted lined box around it.

When a listbox items selected property is set though both the item will
be shown with another color background and also its checkbox will be
seen. This regardless if the listbox has focus or not.

I was hoping for it to be possible to somehow highlight an item whose
listindex is set but not have its selected property set as well. So
basically to see what items listindex is set even though the listbox
does not have focus.

Thanks for any tips,

Best regards,

Leon v/d Willik
 
G

Guest

Hello, I was just reading your post and I am having the same trouble have you
figured anything out about how to do this if you have could you please
explain how this is done. If i figure it out I will let you know
thanks
skid
 
D

droopy928gt

Sorry skid but I haven't figured it out yet. The good people on this
forum apparently also not.

What I think to know now is that it simply aint possible. You can only
see a non selected item if the listbox has focus. The problem is when
it has focus you can't type.

For anyone else reading, Yeah yeah yeah, I know about the MatchEntry
property. The problem with it though is it aint working. Apart from
that you can't get its typed characters in an editable listbox.

If only there would have been the VB GotFocus and LostFocus instead of
the louzy VBA Enter and Exit events.

Best regards,

Leon
 
G

Guest

hello Leon I got it to work.
this is the code I'm using.

x = EMP.Cells(REC, 10)
UFEmp2.EMPSELECT.Selected(x) = True

emp .cells(REC,10)= emp is the sheet name where the data for the listbox is
stored.
REC is the row number of the current record.
10 is the column that stores the listbox
index number
UFEmp2 = the form name
EMPSELECT = the listbox name
..Select(x) = x is the value stored in the sheet Column 10, Row (REC)

on my user form I have navigation buttons to move the the records, every
time i click on one of these button i call these two lines of code and you
don't have to have focus on the listbox for it to be highlighted. if you have
any question email me at (e-mail address removed) and I will send you a
working copy that you can play with and see if this is what you are trying to
do.

skid
 
D

droopy928gt

Hi Skid,

Thanks for the tip but this is unfortunately not what I was looking
for. What you've found is how to select an item, meaning a blue bar
comes around the item in the listbox and its selected property is set.

When the listbox has focus though and an item is selected without its
selected property being set to true you'll see a box with dotted lines
around the item. This disappears when the listbox looses focus.

Thanks though for letting know the solution that worked for you.

Best regards,

Leon
 

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

Similar Threads


Top