Question fill Combobox in datagridview

saldo

New member
Joined
Aug 17, 2012
Messages
1
Programming Experience
3-5
hello,
I have a datagrid that contains two textboxes and a combobox
I want to fill my combobox with a list of items ... compounds (these compounds related items section component that has the id of the first fields in the datagrid).
So each row of the grid must contain:
<id Article> <désignation Article> <list articles component>


My code is the first two fields are bound to a dataset)
ouvr_cnx ()
colcombo = New DataGridViewComboBoxColumn
DataGridView1.Columns.Add (colcombo)
As New SqlCommand mycommand Sun ("select component from Article have designationArticle, ARTICLE_COMPOSE where (= idArticleComposant Article.idArticle And idArticleComposé =" & DataGridView1.CurrentRow.Cells (0). Value & ")", MyConnection)
Sun mondatareader As SqlDataReader
mondatareader = macommande.ExecuteReader
while mondatareader.Read
colcombo.Items.Add (mondatareader (0))
MsgBox (mondatareader (0))
End While
mondatareader.Close ()
ferm_cnx ()


if anyone can help me ... PCQ vrm
cordially
 
I'd rather store my query in a datatable and then set the entire column with it this way:

Dim MyDataTable As New DataTable
MyDataTable.Load(mondatareader)
        Dim colcombo As New DataGridViewComboBoxColumn
        colcombo.DataSource = MyDataTable

Hope it helps.
 
Back
Top