ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Listboxes and select items in it (https://www.excelbanter.com/excel-programming/351619-listboxes-select-items.html)

droopy928gt[_4_]

Listboxes and select items in it
 

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

--
droopy928g
-----------------------------------------------------------------------
droopy928gt's Profile: http://www.excelforum.com/member.php...fo&userid=3023
View this thread: http://www.excelforum.com/showthread.php?threadid=50565


Toppers

Listboxes and select items in it
 
Hi,

Is this what you want?

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

"droopy928gt" wrote:


Dear all,

I've got a question on listboxes which I can't find an answer for nor
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 set
to options.

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

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

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

OR

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

Thanks for any ideas and tips.

Best regards,

Leon v/d Willik


--
droopy928gt
------------------------------------------------------------------------
droopy928gt's Profile: http://www.excelforum.com/member.php...o&userid=30232
View this thread: http://www.excelforum.com/showthread...hreadid=505659



droopy928gt[_5_]

Listboxes and select items in it
 

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


--
droopy928gt
------------------------------------------------------------------------
droopy928gt's Profile: http://www.excelforum.com/member.php...o&userid=30232
View this thread: http://www.excelforum.com/showthread...hreadid=505659


skid

Listboxes and select items in it
 
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

"droopy928gt" wrote:


Dear all,

I've got a question on listboxes which I can't find an answer for nor
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 set
to options.

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

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

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

OR

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

Thanks for any ideas and tips.

Best regards,

Leon v/d Willik


--
droopy928gt
------------------------------------------------------------------------
droopy928gt's Profile: http://www.excelforum.com/member.php...o&userid=30232
View this thread: http://www.excelforum.com/showthread...hreadid=505659



droopy928gt[_6_]

Listboxes and select items in it
 

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


--
droopy928gt
------------------------------------------------------------------------
droopy928gt's Profile: http://www.excelforum.com/member.php...o&userid=30232
View this thread: http://www.excelforum.com/showthread...hreadid=505659


skid

Listboxes and select items in it
 
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 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

"droopy928gt" wrote:


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


--
droopy928gt
------------------------------------------------------------------------
droopy928gt's Profile:
http://www.excelforum.com/member.php...o&userid=30232
View this thread: http://www.excelforum.com/showthread...hreadid=505659



droopy928gt[_7_]

Listboxes and select items in it
 

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


--
droopy928gt
------------------------------------------------------------------------
droopy928gt's Profile: http://www.excelforum.com/member.php...o&userid=30232
View this thread: http://www.excelforum.com/showthread...hreadid=505659



All times are GMT +1. The time now is 01:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com