VB6: ComboBox with .Style Dropdown List not maintaining .ListIndex setting 
Author Message
 VB6: ComboBox with .Style Dropdown List not maintaining .ListIndex setting

Dear Gurus:

I am looking for work arounds or suggestions for other components to use.
I am using VB6 without any service packs

Normal dropdown list style searching is done only on the first character of
the list values.

I am trying to implement a searchable combobox, that is a combobox that
maintains a search string (upto four chars) across keystrokes.
As the search string grows you move further down the list.

Things seem to work ok except in this situation:
Click on drop down arrow and list appears, start typing and different list
values are highlighted and the textbox portion is updated. Tab out of the
field and the first item with first letter matching last letter typed
replaces that which was highlighted (this appears to be the original default
search method taking over)... not good.

Note: neither _KeyDown nor _KeyUp intercepts the tab key

snippets:
'Assume xyz ComboBox is populated with sorted values

Dim search as String

Private Sub xyz_KeyUp(keycode As Integer, shift As Integer)
    Dim c As String, I As Integer

    c = UCase(Chr(keycode))
    If "A" <= c And c <= "Z" And Len(search) < 4 Then
        search = search + c
    ElseIf keycode = vbKeyBack And search <> "" Then
        search = Mid$(search, 1, Len(search) - 1)
    Else
        Exit Sub
    End If

    For I = 0 To xyz.ListCount - 1
        If xyz.List(I) >= search Then Exit For
    Next I
    xyz.ListIndex = I
End Sub

Private Sub xyz_LostFocus()
    search = ""
End Sub

Rich DeVenezia



Sun, 07 Apr 2002 03:00:00 GMT  
 VB6: ComboBox with .Style Dropdown List not maintaining .ListIndex setting


Fri, 19 Jun 1992 00:00:00 GMT  
 VB6: ComboBox with .Style Dropdown List not maintaining .ListIndex setting
Get the service packs. I think it was on SP2 that the CD had a label that said "Don't attempt to distribute any app written in VB6
without this service pack" or something just as scary.
Quote:

> Dear Gurus:

> I am looking for work arounds or suggestions for other components to use.
> I am using VB6 without any service packs

> Normal dropdown list style searching is done only on the first character of
> the list values.

> I am trying to implement a searchable combobox, that is a combobox that
> maintains a search string (upto four chars) across keystrokes.
> As the search string grows you move further down the list.

> Things seem to work ok except in this situation:
> Click on drop down arrow and list appears, start typing and different list
> values are highlighted and the textbox portion is updated. Tab out of the
> field and the first item with first letter matching last letter typed
> replaces that which was highlighted (this appears to be the original default
> search method taking over)... not good.

> Note: neither _KeyDown nor _KeyUp intercepts the tab key

> snippets:
> 'Assume xyz ComboBox is populated with sorted values

> Dim search as String

> Private Sub xyz_KeyUp(keycode As Integer, shift As Integer)
>     Dim c As String, I As Integer

>     c = UCase(Chr(keycode))
>     If "A" <= c And c <= "Z" And Len(search) < 4 Then
>         search = search + c
>     ElseIf keycode = vbKeyBack And search <> "" Then
>         search = Mid$(search, 1, Len(search) - 1)
>     Else
>         Exit Sub
>     End If

>     For I = 0 To xyz.ListCount - 1
>         If xyz.List(I) >= search Then Exit For
>     Next I
>     xyz.ListIndex = I
> End Sub

> Private Sub xyz_LostFocus()
>     search = ""
> End Sub

> Rich DeVenezia



Sun, 07 Apr 2002 03:00:00 GMT  
 VB6: ComboBox with .Style Dropdown List not maintaining .ListIndex setting
Installed SP3 and have the same behaviour of losing the .listindex setting.

I am using this in xyz_KeyUp
    .ListIndex = ...;
    SendKeys "{UP}{DOWN}"
to force the component to maintain the .ListIndex I want. Ugly but it works.


Quote:
> Get the service packs. I think it was on SP2 that the CD had a label that

said "Don't attempt to distribute any app written in VB6
Quote:
> without this service pack" or something just as scary.




Quote:
> > Dear Gurus:

> > I am looking for work arounds or suggestions for other components to
use.
> > I am using VB6 without any service packs

> > Normal dropdown list style searching is done only on the first character
of
> > the list values.

> > I am trying to implement a searchable combobox, that is a combobox that
> > maintains a search string (upto four chars) across keystrokes.
> > As the search string grows you move further down the list.

> > Things seem to work ok except in this situation:
> > Click on drop down arrow and list appears, start typing and different
list
> > values are highlighted and the textbox portion is updated. Tab out of
the
> > field and the first item with first letter matching last letter typed
> > replaces that which was highlighted (this appears to be the original
default
> > search method taking over)... not good.

> > Note: neither _KeyDown nor _KeyUp intercepts the tab key

> > snippets:
> > 'Assume xyz ComboBox is populated with sorted values

> > Dim search as String

> > Private Sub xyz_KeyUp(keycode As Integer, shift As Integer)
> >     Dim c As String, I As Integer

> >     c = UCase(Chr(keycode))
> >     If "A" <= c And c <= "Z" And Len(search) < 4 Then
> >         search = search + c
> >     ElseIf keycode = vbKeyBack And search <> "" Then
> >         search = Mid$(search, 1, Len(search) - 1)
> >     Else
> >         Exit Sub
> >     End If

> >     For I = 0 To xyz.ListCount - 1
> >         If xyz.List(I) >= search Then Exit For
> >     Next I
> >     xyz.ListIndex = I
> > End Sub

> > Private Sub xyz_LostFocus()
> >     search = ""
> > End Sub

> > Rich DeVenezia



Sun, 07 Apr 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. ComboBox with Style set as DropDown List: Problem.

2. Newbie: Set a combo box style(2)/Dropdown list to the first element in the list

3. Newbie: Set a combo box style(2)/Dropdown list to the first element in the list

4. Newbie: Set a combo box style(2)/Dropdown list to the first element in the list

5. Combobox (Dropdown List: Style=2)

6. Checkmark in Dropdown List Style Combobox

7. ComboBox - Dropdown List Style

8. Dynamically creating combobox with Style=2 - Dropdown List?

9. ComboBox (Style -> Dropdown List) Change() event

10. ComboBox - Style 2 - Dropdown List

11. ComboBox: Style(2 - DropDown List), change value?

12. Key Press in ComboBox when style is DropDown is not working

 

 
Powered by phpBB® Forum Software