L'auto complétion d'un textBox avec un "Like" et non par "Commence par"
Bonjour tout le monde
Je travail sur un projet VS2010, client lourd.
J'ai besoin de développer un composant qui filtre une liste avec un paramètre LIKE
Dans mon textBox, si je tape "Ber", il doit me proposer tout les noms qui contiennent "ber"
J'ai deja développé un code qui fonctionne, mais je ne récupère pas toujours le bon item sélectionné !!
Si vous trouvez une faille dans mon code ou vous avez une autres méthode je suis preneur
Merci par avance
Aigle
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| Private Sub Cb_Nom_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Cb_Nom_Rech.SelectedValueChanged
Try
If boolActeur And Cb_Nom_Rech.SelectedItem IsNot Nothing And Cb_Nom_Rech.SelectedItem.Text.Trim <> "" Then
_acteur = CType(CType(Cb_Nom_Rech.SelectedItem, ListItem).Value, Acteur)
Cb_Adresse.DataSource = BllAdresse.Get_ListItemAdressesByIdActeur(_acteur.Id)
If Not (boolpmt And boolremb And Not _adresse_Fin_bis.Pmt And Not _adresse_Fin_bis.Remb) Then
Cb_Adresse_Fin.DataSource = BllAdresse_Fin.Get_ListItemAdresses_Fin(_acteur.Id)
End If
chargerActeur()
End If
Catch ex As Exception
RegiesLog.AddLog("MESSAGE : " & ex.Message & ControlChars.CrLf & " DETAIL : " & ex.StackTrace & ControlChars.CrLf, EventLogEntryType.Error, RegiesLog.LogDetailLevel.Full)
End Try
Private Sub Cb_Nom_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Cb_Nom_Rech.TextChanged
Try
If Cb_Nom_Rech.Text.Length > 3 And nom <> Cb_Nom_Rech.Text And boolActeur Then
nom = Cb_Nom_Rech.Text
boolActeur = False
Dim lst As List(Of ListItem) = BllActeur.Get_ListItemActeurs(Cb_Nom_Rech.Text)
If lst.Count <> 0 Then
Cb_Nom_Rech.DataSource = lst
Else
Try
lst.Add(New ListItem("", ""))
Cb_Nom_Rech.DataSource = lst
Catch ex As Exception
End Try
End If
If Cb_Nom_Rech.Items.Count > 1 Then
Me.Cb_Nom_Rech.DroppedDown = True
Else
cb_creerActeur.Visible = True
End If
Cb_Nom_Rech.Text = nom
Me.Cb_Nom_Rech.SelectionStart = Me.Cb_Nom_Rech.Text.Length
Cursor.Current = Cursors.Default
boolActeur = True
Else
If boolActeur Then
nom = Cb_Nom_Rech.Text
Me.Cb_Nom_Rech.DroppedDown = False
Cb_Nom_Rech.DataSource = Nothing
Cb_Nom_Rech.Items.Add(New ListItem("", ""))
Me.Cb_Nom_Rech.SelectionStart = Me.Cb_Nom_Rech.Text.Length
Cb_Nom_Rech.Text = nom
End If
End If
Catch ex As Exception
RegiesLog.AddLog("MESSAGE : " & ex.Message & ControlChars.CrLf & " DETAIL : " & ex.StackTrace & ControlChars.CrLf, EventLogEntryType.Error, RegiesLog.LogDetailLevel.Full)
End Try
End Sub
End Sub |