[.Net] Remplir un ComboBox
'Remplir un combo
Public Sub RemplirTypeFluxBext(ByRef p_ctrl As ComboBox)
Dim msqlCnx As SqlConnection
Dim msqlCmd As SqlCommand
Try
'p_ctrl.Items.Clear()
msqlCnx = New SqlConnection()
msqlCnx.ConnectionString = chaineConnexion()
msqlCnx.Open()
msqlCmd = New SqlCommand
With msqlCmd
.Connection = msqlCnx
.CommandType = CommandType.StoredProcedure
.CommandText = "usp_Client_Select"
End With
Dim DataAdapter As New SqlDataAdapter(msqlCmd)
Dim ds As New DataSet
DataAdapter.Fill(ds, "TypeFluxBext")
With p_ctrl
.DataSource = ds.Tables("ListeClient")
.DisplayMember = "Nom_Client"
.ValueMember = "Id_Client"
'.SelectedIndex = -1
End With
Catch ex As Exception
MsgBox(ex.ToString, MsgBoxStyle.Critical, CST_TITRE_MSGBOX)
Finally
End Try
msqlCnx.Close()
msqlCnx = Nothing
msqlCmd = Nothing
End Sub