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
| '******************************Auto complete**************************************
Private Sub supprimerarticle_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf FillAutoComplete))
End Sub
Private Sub FillAutoComplete(ByVal state As Object)
Dim res As AutoCompleteStringCollection = New AutoCompleteStringCollection()
Using scon As New SqlConnection("Data Source=MTIRI-PC; Initial Catalog=base-ets-mtiri;integrated security=true; ")
Using scom As New SqlCommand("", scon)
scom.CommandText = String.Format("SELECT desig_article FROM article ", Me.textbox1.Text.ToLower())
scon.Open()
Dim reader As SqlDataReader = scom.ExecuteReader
While reader.Read()
res.Add(reader.GetString(0))
End While
reader.Close()
scon.Close()
End Using
End Using
If res.Count <> 0 Then
SetSource(res)
End If
End Sub
Private Delegate Sub SetSourceDelegate(ByVal source As AutoCompleteStringCollection)
Private Sub SetSource(ByVal source As AutoCompleteStringCollection)
If Me.InvokeRequired Then
Me.Invoke(New SetSourceDelegate(AddressOf SetSource), source)
Else
Me.textbox1.AutoCompleteCustomSource = source
End If
End Sub |
Partager