Click here to Skip to main content
15,302,644 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to add multiple Datagridviewcomboboxcolumn in datagrid in win application and to update those columns also from the value.

I have added the combobox column by setting different datatable as datasource but when i change the value of one combobox then all the combobox value changes

does anyone one has the code or application to help in this.
Kschuler 20-Dec-10 13:54pm
Could you post the relevant code you are using, please.
nitin_ion 20-Dec-10 14:37pm
code is added

Public Class Form1
    Dim mcn As MySqlConnection
    Dim mcm As MySqlCommand
    Dim mda As New MySqlDataAdapter
    Dim mdt As New DataTable
    Dim mds As New DataSet
    Dim str As String
    Dim value As String

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        str = "server=localhost;uid=root;pwd=bss;database=cdetail"
        mcn = New MySqlConnection
        mcn.ConnectionString = str

        End Sub

    Private Sub FillGridView()

        '--- Adding the values into the combo box through the List---
        Dim cmbOpt1 As DataGridViewComboBoxColumn = CType(DataGridView1.Columns("loc"), DataGridViewComboBoxColumn)
        Dim cmbOpt2 As DataGridViewComboBoxColumn = CType(DataGridView1.Columns("PRODUCT"), DataGridViewComboBoxColumn)

            str = "select Name,fullname from others order by Name"
            mda = New MySqlDataAdapter(str, mcn)
            Dim mdt1 As New DataTable
            'If loc.DataSource Is Nothing Then
            cmbOpt1.DataSource = mdt1
            cmbOpt1.DisplayMember = "Name"
            cmbOpt1.ValueMember = "fullname"

            Dim str2 As String
            Dim mda1 As New MySqlDataAdapter
            Dim mdt2 As New DataTable
            str2 = "select productname,fullname from product order by productname"
            mda = New MySqlDataAdapter(str2, mcn)
            cmbOpt2.DataSource = mdt2
            cmbOpt2.DisplayMember = "productname"
            cmbOpt2.ValueMember = "fullname"

        Catch ex As Exception
        End Try

    End Sub

End Class
Toniyo Jackson 21-Dec-10 4:39am
Dont add your question here. You can add in question by clicking Improve Answer.
Public SqlCon As New System.Data.SqlClient.SqlConnection("server=??? Servername or . for local??;user id=???UserName???;pwd=???Password???;data source=???Server Name or .???;database=?? Database name ???")
Dim tbl As New DataTable
Dim dvw As DataView
Dim b As Boolean
Dim cmd As New SqlClient.SqlCommand("SELECT * FROM Personalinfo", sqlcon)
Dim sdr As SqlClient.SqlDataReader = cmd.ExecuteReader
Dim fc As Integer
While (sdr.Read)
    'populating columns
    If Not b Then
        For fc = 0 To sdr.FieldCount - 1
        b = True
    End If
    'populating rows
    Dim row As DataRow = tbl.NewRow
    For fc = 0 To sdr.FieldCount - 1
        row(fc) = sdr(fc)
End While
dvw = New DataView(tbl)
Me.dgrPersonalInfo.DataSource = dvw

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900