I am using a datagridview to populate an Access Database to a form in VB.net. I want to perform certain actions (validation/updating database) when a user changes values in a row. I want to wait until the row loses focus to perform the changes. I am using the RowLeave event to perform the tasks. The problem is that when the form with the datagridview loads, it automatically runs the RowLeave event.
How do I go about having the form load and not have the RowLeave event from running? What is causing the RowLeave event to be triggered upon loading of the form?
EDIT: This is part of my code:
Public Sub loadGradeForm(ByRef temp As Teacher)
currTeacher = temp
Me.showGrades() 'Populating the datagridview (GradeGridView)
Me.Show()
'After the form loads, it automatically goes to RowLeave when I go through debugging
End Sub
Private Sub showGrades()
GradeGridView.DataSource = Nothing
GradeGridView.Rows.Clear()
GradeGridView.Columns.Clear()
GradeGridView.AutoGenerateColumns = False
GradeGridView.AutoSize = True
GradeGridView.DataSource = currTeacher.ListOfClasses()
Dim column0 As DataGridViewColumn = New DataGridViewTextBoxColumn()
column0.DataPropertyName = "Class"
column0.Name = "Class"
GradeGridView.Columns.Add(column0)
Dim column As DataGridViewColumn = New DataGridViewTextBoxColumn()
column.DataPropertyName = "Grade"
column.Name = "Grade"
GradeGridView.Columns.Add(column)
Dim column1 As DataGridViewColumn = New DataGridViewTextBoxColumn()
column1.DataPropertyName = "Semester"
column1.Name = "Semester"
GradeGridView.Columns.Add(column1)
End Sub
Private Sub GradeGridView_RowLeave(sender As Object, e As DataGridViewCellEventArgs) Handles GradeGridView.RowLeave
MsgBox(e.RowIndex)
'This is just a test to see if RowLeave is triggered
End Sub