0/5 (7 avis)
Vue 16 972 fois - Téléchargée 3 310 fois
' M O D U L E '-------------------------------------------------------------------------------- ' www.idev.fr.st ' ' Syntax ' ------ ' In the CHANGE event of your ComboBox, put in the following line ' iSenseChange YourComboBoxName ' Where "YourComboBoxName" is the name of the ComboBox associated with the event. ' ' In the KEYPRESS event of your ComboBox, put in the following line ' iSenseKeyPress YourComboBoxName, KeyAscii ' Where "YourComboBoxName" is the name of the ComboBox associated with the event.' ' ' ADAPTED FROM : '-------------------------------------------------------------------------------- ' IntelliSense for VB the TextBox Control. ' Danny Young ' dan@mydan.com ' http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=9313&lngWId=1 '-------------------------------------------------------------------------------- Option Explicit Global WasDelete As Boolean Public Function IntelliSense(cBox As ComboBox, AddRecord As Boolean) As String Dim i As Integer Dim Done As Boolean If AddRecord Then 'Pour ajouter le texte dans la ComboBox 'cBox.AddItem cBox.Text Else ' For i = 0 To cBox.ListCount And Done = False For i = cBox.ListCount To 0 Step -1 And Done = False If UCase(cBox.Text) = Mid(RTrim(UCase(cBox.List(i))), 1, Len(cBox.Text)) Then IntelliSense = RTrim(cBox.List(i)) End If Next i End If End Function Public Sub iSenseChange(cBox As ComboBox) Dim iStart As Integer Dim iSense As String iStart = cBox.SelStart iSense = IntelliSense(cBox, False) If iSense <> "" And Not WasDelete Then cBox.Text = iSense cBox.SelStart = iStart cBox.SelLength = Len(cBox.Text) - iStart End If End Sub Public Sub iSenseKeyPress(cBox As ComboBox, KeyAscii As Integer) If KeyAscii = 13 And cBox.Text <> "" Then IntelliSense cBox, True ElseIf KeyAscii = 8 Then WasDelete = True Else WasDelete = False End If End Sub
17 sept. 2008 à 13:39
j'ai assaié de faire ça depuis longtemp mais j'ai pas pu avec niveau professionel
7 sept. 2005 à 14:16
merci pour ce code qui est trés utile, mais est ce que il existe des methodes pour eleminer les doublons de cette combobox
et merci
said.saadani@gmail.com
2 juil. 2005 à 12:55
23 mai 2003 à 10:13
1 avril 2003 à 20:53
Merci à Samisamu pour ses suggestions.
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.