Zdravim. Ziskavam udaj z datagridview, kt. je naviazany na dataset cez bindingsource. Ak nie je v datagride ziaden riadok, tak samozrejme program zhavaruje: Object reference not set to an instance of an object. Co je pochopitelne. Ako osetrit tento stav? Myslim zistit ze object nie je nastaveny. Tu je kod:
Private Sub nova_but_Click(sender As Object, e As EventArgs) Handles nova_but.Click
Try
Dim w As New f_cp_nova
w.cp1_prop = podf1.CurrentRow.Cells("cp_podf1").Value
w.ShowInTaskbar = False
w.ShowDialog()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Mam na mysli aby som pred nacitanom hodnoty do w.cp1 zistil ci je podf1.currentrow.cells("cp_podf1") vobec nastavene. Nieco ako :
if podf1.CurrentRow.Cells("cp_podf1").Value = nothing then
msgbox ("Nie je zadane.")
else
Dim w As New f_cp_nova
w.cp1_prop = podf1.CurrentRow.Cells("cp_podf1").Value
w.ShowInTaskbar = False
w.ShowDialog()
end if
|