i have combobox column and on selection of the combobox data i want the text field column of the datagrid view to get the text based on the selection of the data in the combobox column
the text in the textbox will come from the database based on data selected in combobox
i have done the bit its not working it is giving "Object reference not set to an instance of an object".
code is
can any one help me
Public cb As ComboBox
Private Sub dgv_assign_dboy_EditingControlShowing(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) _
Handles dgv_assign_dboy.EditingControlShowing
' Attempt to cast the EditingControl to a ComboBox.
cb = TryCast(e.Control, ComboBox)
If cb IsNot Nothing Then
RemoveHandler cb.SelectedIndexChanged, AddressOf DGVComboIndexChanged
AddHandler cb.SelectedIndexChanged, AddressOf DGVComboIndexChanged
End If
End Sub
Private Sub DGVComboIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
'using the value selected in the cbox to find and insert the right value in the textbox
strselect = "select fname from dboy where d_id='" & Trim(cb.SelectedValue.ToString) & "'"
rstt = sqlconnect.readquery(strselect)
If rstt.HasRows = True Then
While rstt.Read
dgv_assign_dboy.Item(0, dgv_assign_dboy.CurrentCell.RowIndex).Value = rstt(0).ToString
End While
End If