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.
Expand|Select|Wrap|Line Numbers
- 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