ComboBox with Autocomplete and ListIndex 
Author Message
 ComboBox with Autocomplete and ListIndex

Hi everyone,

I use autocomplete (from planet source code web site) in my combobox. I also
use the following code:

    combo1.AddItem "Tesing 1"
        combo1.ItemData(combo1.NewIndex) = 12345
    combo1.AddItem "Tesing 2"
        combo1.ItemData(combo1.NewIndex) = 23456

So when I select that item, I have the ListIndex number associate with that
item.

msgbox combo1.ItemData(combo1.ListIndex)

But when I use autocomplete, it works fine but not the right ListIndex
number, always gives me ListIndex number = -1.

Did I do something wrong? Please help.



Fri, 15 Nov 2002 03:00:00 GMT  
 ComboBox with Autocomplete and ListIndex
The ListIndex property tells you where you are currently in the list or
combo box. If there is no selection highlighted in the box when the msgbox
fires, then you will get -1 (default for "No selection")... otherwise it
will return to you where you are in the list...

Private Sub Listbox1_OnClick()
    msgbox "Place in List: " & Listbox1.ListIndex & vbcrlf & "Number of
Items: " & Listbox1.ListCount
End Sub

When you click on an item in the listbox, it will message you with what
position you are at.

Now, for your problem.. don't use the ItemData method to set the index.. use
the [Index] argument in the AddItem method to set the index. ie...

Combo1.AddItem "Item1", 12345
-OR-
Combo1.AddItem "Item1", combo1.listcount +1 (or whatever number you want...)

Then it should index correctly.

Hope this helps..

Bill Priess


Quote:
> Hi everyone,

> I use autocomplete (from planet source code web site) in my combobox. I
also
> use the following code:

>     combo1.AddItem "Tesing 1"
>         combo1.ItemData(combo1.NewIndex) = 12345
>     combo1.AddItem "Tesing 2"
>         combo1.ItemData(combo1.NewIndex) = 23456

> So when I select that item, I have the ListIndex number associate with
that
> item.

> msgbox combo1.ItemData(combo1.ListIndex)

> But when I use autocomplete, it works fine but not the right ListIndex
> number, always gives me ListIndex number = -1.

> Did I do something wrong? Please help.



Fri, 15 Nov 2002 03:00:00 GMT  
 ComboBox with Autocomplete and ListIndex
Hi William,

Thanks for your quick response.
For some reason, I couldn't even add the item the to combo box.
combo1.AddItem "Item1", 10                                         ' this
line didn't add
combo1.AddItem "Item1", combo1.ListCount + 10        ' this line didn't add

Did I do something wrong here? Thanks.


Quote:
> The ListIndex property tells you where you are currently in the list or
> combo box. If there is no selection highlighted in the box when the msgbox
> fires, then you will get -1 (default for "No selection")... otherwise it
> will return to you where you are in the list...

> Private Sub Listbox1_OnClick()
>     msgbox "Place in List: " & Listbox1.ListIndex & vbcrlf & "Number of
> Items: " & Listbox1.ListCount
> End Sub

> When you click on an item in the listbox, it will message you with what
> position you are at.

> Now, for your problem.. don't use the ItemData method to set the index..
use
> the [Index] argument in the AddItem method to set the index. ie...

> Combo1.AddItem "Item1", 12345
> -OR-
> Combo1.AddItem "Item1", combo1.listcount +1 (or whatever number you
want...)

> Then it should index correctly.

> Hope this helps..

> Bill Priess



> > Hi everyone,

> > I use autocomplete (from planet source code web site) in my combobox. I
> also
> > use the following code:

> >     combo1.AddItem "Tesing 1"
> >         combo1.ItemData(combo1.NewIndex) = 12345
> >     combo1.AddItem "Tesing 2"
> >         combo1.ItemData(combo1.NewIndex) = 23456

> > So when I select that item, I have the ListIndex number associate with
> that
> > item.

> > msgbox combo1.ItemData(combo1.ListIndex)

> > But when I use autocomplete, it works fine but not the right ListIndex
> > number, always gives me ListIndex number = -1.

> > Did I do something wrong? Please help.



Fri, 15 Nov 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ComboBox with Autocomplete and ListIndex

2. Combobox autoexpand or autocomplete?

3. combobox autocomplete

4. Autocomplete Combobox - In Hebrew

5. ComboBox AutoComplete

6. ComboBox Autocomplete?

7. Combobox Autocomplete

8. Combobox and Autocomplete

9. ComboBox listindex????

10. listindex property for combobox

11. VB5 ComboBox ListIndex appears to become reset to zero

12. Combobox & Listindex

 

 
Powered by phpBB® Forum Software