[VB6] ComboBox autocompletion
Bonjour, je voulais savoir si en VB6, l'autocompletion est déjà présente ou il faut la faire soi-même?
Dans mon projet j'ai un combobox qui possède 150 items (lignes), si l'utilisateur veut chercher, il ne doit pas tout dérouler la liste et c'est long, faut lire un par un si ce n'est pas trié alphabétiquement.
Donc quand l'utilisateur tape un début de lettre ou mot, le combobox se déroule et propose seulement les items dont la chaine commence par ce qu'il a taper.. voila je crois avoir bien expliquer l'autocompletion ou l'intelisense
En bref, je voulais savoir comment fait-on? y'a-t-il des exemples? sources?
voila merci
Un code qui marche pas trop mal avec un combobox
Désolé c'est peut être pas le plus source que vous verrez :mouarf: , mais ça fonctionne correctement :yaisse2:
Philippe
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
' Dans (Général) (déclaration)
Dim thekey As Integer
Dim theshift As Integer
Private Sub Combo1_Change()
Dim i As Integer, start As Integer
Dim ShiftDown As Boolean
Dim CtrlDown As Boolean
Dim AltDown As Boolean
ShiftDown = (theshift And vbShiftMask) > 0
CtrlDown = (theshift And vbCtrlMask) > 0
AltDown = (theshift And vbAltMask) > 0
If thekey = vbKeyLeft Or thekey = vbKeyRight Or thekey = vbKeyUp Or thekey = vbKeyDown _
Or thekey = vbKeyBack Or thekey = vbKeyDelete Or ShiftDown Or AltDown Or CtrlDown Then
' Nothing to do now !...maybe later ;-)
Else
start = Len(Combo1.Text)
For i = 0 To Combo1.ListCount - 1
If Left(Combo1.List(i), start) = Combo1.Text Then
Combo1.Text = Combo1.List(i)
End If
Next
Combo1.SelStart = start
Combo1.SelLength = Len(Combo1.Text)
End If
End Sub
Private Sub Combo1_KeyUp(KeyCode As Integer, Shift As Integer)
thekey = KeyCode
theshift = Shift
End Sub |