» »

Autocomplete problemček...

Autocomplete problemček...

erik ::

Živjo !

Imam majhen problemček z autodopolnitvijo Combo gradnika.
Imam naslednjo kodo, katero sem našel na netu:

_______________________________________________________________
Private Sub cmbSpremljevalec_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDelete Then
cmbSpremljevalec.Text = ""
KeyCode = 0
End If
End Sub
________________________________________________________________
Private Sub cmbSpremljevalec_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 13 ' key ENTER
SendKeys "{Tab}"
End Select
KeyAscii = CapsLock(KeyAscii)
'-------------------------------------------------------- autodopolnitev
Dim strSearchText As String
Dim strEnteredText As String
Dim intLength As Integer
Dim intIndex As Integer
Dim intCounter As Integer
On Error GoTo ErrorHandler


With cmbSpremljevalec


If .SelStart > 0 Then
strEnteredText = Left(.Text, .SelStart)
End If


Select Case KeyAscii
Case vbKeyReturn


If .ListIndex > -1 Then
.SelStart = 0
.SelLength = Len(.List(.ListIndex))
Exit Sub
End If
Case vbKeyEscape, vbKeyDelete
.Text = ""
KeyAscii = 0
Exit Sub
Case vbKeyBack


If Len(strEnteredText) > 1 Then
strSearchText = LCase(Left(strEnteredText, Len(strEnteredText) - 1))
Else
strEnteredText = ""
KeyAscii = 0
.Text = ""
Exit Sub
End If
Case Else
strSearchText = LCase(strEnteredText & Chr(KeyAscii))
End Select
intIndex = -1
intLength = Len(strSearchText)


For intCounter = 0 To .ListCount - 1


If LCase(Left(.List(intCounter), intLength)) = strSearchText Then
intIndex = intCounter
Exit For
End If
Next intCounter


If intIndex > -1 Then
.ListIndex = intIndex
.SelStart = Len(strSearchText)
.SelLength = Len(.List(intIndex)) - Len(strSearchText)
Else
Beep
End If
End With
KeyAscii = 0
Exit Sub
ErrorHandler:
KeyAscii = 0
Beep
End Sub
______________________________________________________________

Vse deluje lepo in prav, vendar če hočem polje pustiti prazno in grem na naslednji Combo z tipko Enter (glej kodo) potem
mi zapolni Combo z prvo vrednostjo iz Combo seznama. Če pa grem na nasl. polje z tipko Tab, potem polje ostane prazno.
Kje v kodi je zankica... mogoče mi lahko kdo pomaga??

Hvala!

darkolord ::

ne vem sicer kaj hočeš: da polje ostane prazno, ko pritisneš enter ali da se uporabi prva vrednost ko uporabiš tipko tab?

če hočeš samo preklopiti na naslednji combo, namesto SendKeys "{Tab}" uporabi Combo2.SetFocus


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

vb.net: dynamic textbox

Oddelek: Programiranje
51161 (1051) saule
»

kopiranje iz enega fajla v drug??

Oddelek: Programiranje
131196 (956) Seth
»

VB in kk dobit Ip od račnalnika

Oddelek: Programiranje
81188 (1022) alesrosina
»

API+VB

Oddelek: Programiranje
262066 (1770) webblod
»

Odpiranje dat.exe v VB

Oddelek: Programiranje
122956 (2749) webblod

Več podobnih tem