locked
How to compare the value of DataGridViewComboboxColumn in datagridView RRS feed

  • Question

  • Hi,
    My application is in VS2008 coded in Vb.net
    I have a datagridView on one of my form.This is filled from the database at the load event of the form.The datagridView also has a column of type DatagridViewComboboxcolumn.
    This DatagridViewComboboxcolumn already has 4 values added to it in its collection during design time.My requirement is when the data is loaded in the datagridview, the corresponding record which is supposed to be loaded in DatagridViewComboboxcolumn should compare its value with the value of DatagridViewComboboxcolumn.And if the value matches than that value should get selected in DatagridViewComboboxcolumn.
    The database will have the any of the 4 values that are already in DatagridViewComboboxcolumn.It just has to compare both values and select the matching value.
    Below is my Code

    query= "Select Record1,Record2,Record3 from TableName"
            cmd = New SqlCommand(query, connection)
            dr = cmd.ExecuteReader()
            If dr.HasRows Then
                While dr.Read()
                    datagridView.rows.add(dr(0),dr(1),dr(2))
     
                End While
            End If
    
    dr(2) is supposed to compare the record with DatagridViewComboboxcolumn.
    How can i compare it with the value of my DatagridViewComboboxcolumn of my datagridView 
    Please suggest.

    Thursday, September 15, 2011 8:55 AM