hello,
i wrote a code for when i select a row in the datagridview, the columns values appears in every related text box but everytime i try to click the mouse on a row an error occurs saying that "there is no row at position 0".
code:
Imports System.Data.SqlClient
Public Class Professor Dim inc As Integer
Dim tt As New DataTable
Dim r As DataRow
Private Sub DataGridView1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseUp
Dim rc As Integer
rc = DataGridView1.CurrentRow.Index
inc = rc
getprof(rc)
End Sub
Public Sub getprof(ByVal i As Integer)
r = tt.Rows(i)
prof_lname.Text = r("nom_prof")
prof_fname.Text = r("prenom_prof")
prof_birthdate.Text = r("datenaiss_prof")
prof_email.Text = r("email_prof")
prof_telephone.Text = r("numtel_prof")
prof_username.Text = r("username")
prof_password.Text = r("password")
prof_nationalite.Text = r("nationalite")
prof_gender.Text = r("desc_sexe")
prof_address.Text = r("address_prof")
End Sub
End Class
thank you in advance.
i wrote a code for when i select a row in the datagridview, the columns values appears in every related text box but everytime i try to click the mouse on a row an error occurs saying that "there is no row at position 0".
code:
Imports System.Data.SqlClient
Public Class Professor Dim inc As Integer
Dim tt As New DataTable
Dim r As DataRow
Private Sub DataGridView1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseUp
Dim rc As Integer
rc = DataGridView1.CurrentRow.Index
inc = rc
getprof(rc)
End Sub
Public Sub getprof(ByVal i As Integer)
r = tt.Rows(i)
prof_lname.Text = r("nom_prof")
prof_fname.Text = r("prenom_prof")
prof_birthdate.Text = r("datenaiss_prof")
prof_email.Text = r("email_prof")
prof_telephone.Text = r("numtel_prof")
prof_username.Text = r("username")
prof_password.Text = r("password")
prof_nationalite.Text = r("nationalite")
prof_gender.Text = r("desc_sexe")
prof_address.Text = r("address_prof")
End Sub
End Class
thank you in advance.