[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.vb.general.discussion

Datagridview Combobox Values

JB

7/22/2010 8:40:00 PM

Good Afternoon All,

I have a datagridview dgv1 that has a combobox column in it. Each row
should have an individual item to select from in the combobox. My code
displays the same values in all of them. Any help would be great!

Here's my code:

Dim dsMP As DataSet = New DataSet()

Dim intRow As Integer = 0
Dim intRows As Integer = dgvRO.Rows.Count

Dim strPartNumber As String = ""
Dim dt As DataTable = Nothing
Dim dr As DataRow = Nothing

For intRow = 0 To intRows - 1

strPartNumber = dgvRO.Rows(intRow).Cells("partno").Value

'LOAD DATASET WITH RESLOLUTION VALUES
With clsMP
.Owner = cboCompany.Text
dsMP = .GetAuthorizedVendors(strPartNumber)
End With

dgvRO.CurrentCell = dgvRO.Rows(intRow).Cells("cbovendor")
CType(dgvRO.Columns("cbovendor"),
DataGridViewComboBoxColumn).DataSource = dsMP.Tables(0)
CType(dgvRO.Columns("cbovendor"),
DataGridViewComboBoxColumn).DisplayMember = "vendor"
CType(dgvRO.Columns("cbovendor"),
DataGridViewComboBoxColumn).ValueMember = "vendor"

Next

dsMP.Dispose()

There are currently 5 rows. Each should have a different value in the
combobox, but they don't. What am I doing wrong???

Thanks.

jb
2 Answers

Bob Butler

7/22/2010 10:10:00 PM

0


"jb" <jb@discussions.microsoft.com> wrote in message
news:2061211D-A2E4-4D98-863A-51883802AA6C@microsoft.com...
> Good Afternoon All,
>
> I have a datagridview dgv1 that has a combobox column in it. Each row
> should have an individual item to select from in the combobox. My code
> displays the same values in all of them. Any help would be great!
>
> Here's my code:
>
> Dim dsMP As DataSet = New DataSet()

this group is for VB6 and earlier; VB.Net questions need to go to wherever
they support that language.

Cor Ligthert [MVP]

7/23/2010 5:55:00 AM

0

http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thre...

"jb" <jb@discussions.microsoft.com> wrote in message
news:2061211D-A2E4-4D98-863A-51883802AA6C@microsoft.com...
> Good Afternoon All,
>
> I have a datagridview dgv1 that has a combobox column in it. Each row
> should have an individual item to select from in the combobox. My code
> displays the same values in all of them. Any help would be great!
>
> Here's my code:
>
> Dim dsMP As DataSet = New DataSet()
>
> Dim intRow As Integer = 0
> Dim intRows As Integer = dgvRO.Rows.Count
>
> Dim strPartNumber As String = ""
> Dim dt As DataTable = Nothing
> Dim dr As DataRow = Nothing
>
> For intRow = 0 To intRows - 1
>
> strPartNumber = dgvRO.Rows(intRow).Cells("partno").Value
>
> 'LOAD DATASET WITH RESLOLUTION VALUES
> With clsMP
> .Owner = cboCompany.Text
> dsMP = .GetAuthorizedVendors(strPartNumber)
> End With
>
> dgvRO.CurrentCell = dgvRO.Rows(intRow).Cells("cbovendor")
> CType(dgvRO.Columns("cbovendor"),
> DataGridViewComboBoxColumn).DataSource = dsMP.Tables(0)
> CType(dgvRO.Columns("cbovendor"),
> DataGridViewComboBoxColumn).DisplayMember = "vendor"
> CType(dgvRO.Columns("cbovendor"),
> DataGridViewComboBoxColumn).ValueMember = "vendor"
>
> Next
>
> dsMP.Dispose()
>
> There are currently 5 rows. Each should have a different value in the
> combobox, but they don't. What am I doing wrong???
>
> Thanks.
>
> jb
>