A voir également:
- Remplir un combobox dans VB.Net (urgent SVP)
- Organigramme a remplir word - Guide
- Remplir et signer pdf - Guide
- Comment remplir un chèque bnp - Télécharger - Comptabilité & Facturation
- Fiche de paie à remplir gratuit pdf ✓ - Forum compta / gestion
- Remplir combobox vba ✓ - Forum Excel
2 réponses
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim tab() As String = {"a", "b", "x", "r"}
ComboBox1.DataSource = tab
End Sub
Dim tab() As String = {"a", "b", "x", "r"}
ComboBox1.DataSource = tab
End Sub
Salut Nathalie,
Voici un exemple, a+
Sub RemplirComboTOTO()
Dim cmdSelect As OleDbCommand = New OleDbCommand
Dim drListeTOTO As OleDbDataReader
OuvrirConnexion()
With cmdSelect
.Connection = cnBdD
.CommandType = CommandType.Text
.CommandText = "SELECT * FROM TOTO"
End With
drListeTOTO = cmdSelect.ExecuteReader()
While drListeTOTO.Read()
ComboBoxTOTO.Items.Add(drListeTOTO!TOTOCHAMPS)
End While
drListeTOTO.Close()
FermerConnexion()
End Sub
Sub OuvrirConnexion()
sConnexion = "Provider=Microsoft.Jet.OLEDB.4.0;"
sConnexion &= "Password=;User ID=Admin;"
sConnexion &= "Data Source=C:\TOTO.mdb"
cnBdD = New OleDbConnection(sConnexion)
Try
cnBdD.Open()
Catch ex As Exception
MessageBox.Show(ex.Message, "Message d'alerte", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Sub FermerConnexion()
Try
cnBdD.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Message d'alerte", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Voici un exemple, a+
Sub RemplirComboTOTO()
Dim cmdSelect As OleDbCommand = New OleDbCommand
Dim drListeTOTO As OleDbDataReader
OuvrirConnexion()
With cmdSelect
.Connection = cnBdD
.CommandType = CommandType.Text
.CommandText = "SELECT * FROM TOTO"
End With
drListeTOTO = cmdSelect.ExecuteReader()
While drListeTOTO.Read()
ComboBoxTOTO.Items.Add(drListeTOTO!TOTOCHAMPS)
End While
drListeTOTO.Close()
FermerConnexion()
End Sub
Sub OuvrirConnexion()
sConnexion = "Provider=Microsoft.Jet.OLEDB.4.0;"
sConnexion &= "Password=;User ID=Admin;"
sConnexion &= "Data Source=C:\TOTO.mdb"
cnBdD = New OleDbConnection(sConnexion)
Try
cnBdD.Open()
Catch ex As Exception
MessageBox.Show(ex.Message, "Message d'alerte", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Sub FermerConnexion()
Try
cnBdD.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Message d'alerte", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub