How to compare the value of DataGridViewComboboxColumn in datagridView

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SEhtesham
    New Member
    • Aug 2011
    • 45

    How to compare the value of DataGridViewComboboxColumn in datagridView

    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 DatagridViewCom boboxcolumn.
    This DatagridViewCom boboxcolumn 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 DatagridViewCom boboxcolumn should compare its value with the value of DatagridViewCom boboxcolumn.And if the value matches than that value should get selected in DatagridViewCom boboxcolumn.
    The database will have the any of the 4 values that are already in DatagridViewCom boboxcolumn.It just has to compare both values and select the matching value.
    Below is my Code
    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 DatagridViewCom boboxcolumn.
    How can i compare it with the value of my DatagridViewCom boboxcolumn of my datagridView
    Please suggest.
Working...