Hi,
I have two forms.Both having DatagridView.There are two comboboxes to filter the record from Database and fill in Datagridview.My requirement is when all the data is populated in DataGrid after selecting the comboboxes and when the user clicks on Delete.
The comboboxes and Datagrid on second form should have the same values as that was on first form.The names of my Comboboxes and Datagridview are same on both the forms
Below is the code my Datagrid view getting populated in First Form.

Sub GetData(ByVal StrQuery As String)
        If CBMedium.Text <> "" And CBClass.Text <> "" Then
            DGVStudRecord.Rows.Clear()
            con = DBConnect()
            cmd = New SqlCommand(StrQuery, con)
            dr = cmd.ExecuteReader
            If dr.HasRows Then
                While dr.Read
                  
                    DGVStudRecord.Rows.Add(dr(0), dr(1), dr(2), dr(3), dr(4), dr(5))
                End While
            End If
            con.Close()
        
        End If
    End Sub

Please suggest how can i populate my datagrid in second form by using the Data populated in Datagrid of Firrt Form

When u click on delete button
bind the second grid also with same dataset as firstform

If dr.HasRows Then
                While dr.Read
                  
                    DGVStudRecord.Rows.Add(dr(0), dr(1), dr(2), dr(3), dr(4), dr(5))
                    form2.grid.rows.add(dr(0), dr(1), dr(2), dr(3), dr(4), dr(5))

                End While
            End If

Thanks mate its working accrding to my requirement.I want to do the same for my Comboboxes.
There are two Comboboxes.I want that the as soon as my second form is shown my comboboxes should have the same selected values that are selected on Form one.Comboboxes on boththe forms contains same Elements as they are populated from Database with the same Query at the Load Event of their respective forms.I have tried to use Object as well as the method u showed to fill second Datagrid.Its still not working.
FrmDeleteClassWiseSmsSetting-second Form
CBClass(on left of =)-Combo on second Form
CBClass(on Right of =)-Combo on First Form

FrmDeleteClassWiseSmsSetting.CBClass.SelectedText = CBClass.SelectedText

Thanks mate im Done with my Issues.This is what im doing at the Load of second form to get my combo selected depending on the selection of Combo on First form.

CBClass.SelectedIndex = FrmSMSMobileNumberSetting.CBClass.SelectedIndex
   CBMedium.SelectedIndex = FrmSMSMobileNumberSetting.CBMedium.SelectedIndex

hi Vikram,
Mine is a windows application.

Thanks Mate Vikram.
But im done with my issue.
Thanks for ur concern.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.