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
|
'se servir de AutoCompleteStringCollection()
Private _appareil As New AutoCompleteStringCollection()
Private Sub Frm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
'Dans le Load du formulaire
'cherche les appareils pour remplir la liste du textbox Appareil
MyConnexion.Open() 'ma connection
Mycommand.CommandText = "SELECT DISTINCT TRIM(UPPER(appareil)) FROM equipement "
MyReader = Mycommand.ExecuteReader(CommandBehavior.CloseConnection)
'remplit le AutoCompleteStringCollection()
If MyReader.HasRows Then
Do While MyReader.Read()
_appareil.Add(MyReader.GetString(0))
Loop
End If
With AppareilTextBox
.AutoCompleteCustomSource = _appareil
.AutoCompleteMode = AutoCompleteMode.Suggest
.AutoCompleteSource = AutoCompleteSource.CustomSource
End With
end sub |
Partager