Hi Experts,
I want to check for input validation against a calculated column in datagridview, where if the WorkingHour is more than 8 hours, the system should pop-up a message box and stays at the current row until the input is corrected. This is my code:
Me.dtg.Rows(e.RowIndex).ErrorText = "NT exceed 8 hours!!"
For Each row As DataGridViewRow In dtg.Rows
row.Cells("WorkingHour").Value = row.Cells("NTHour1").Value + row.Cells("NTHour2").Value + row.Cells("NTHour3").Value + row.Cells("NTHour4").Value + row.Cells("NTHour5").Value
If row.Cells("WorkingHour").Value > 8 Then
dtg.Rows(2).Cells(2).Selected = True
dtg.Select()
MsgBox("NORMAL WORKING HOUR IS EXCEED 8 HOURS!", MsgBoxStyle.Critical)
End If
Next
I have tried to put this under the CellEndEdit where the MessageBox working but it's still allow to move to next row. I also tried to put this code under CellValidating but the MessageBox keep on poping until I terminate the program.
Thanks.
I want to check for input validation against a calculated column in datagridview, where if the WorkingHour is more than 8 hours, the system should pop-up a message box and stays at the current row until the input is corrected. This is my code:
Me.dtg.Rows(e.RowIndex).ErrorText = "NT exceed 8 hours!!"
For Each row As DataGridViewRow In dtg.Rows
row.Cells("WorkingHour").Value = row.Cells("NTHour1").Value + row.Cells("NTHour2").Value + row.Cells("NTHour3").Value + row.Cells("NTHour4").Value + row.Cells("NTHour5").Value
If row.Cells("WorkingHour").Value > 8 Then
dtg.Rows(2).Cells(2).Selected = True
dtg.Select()
MsgBox("NORMAL WORKING HOUR IS EXCEED 8 HOURS!", MsgBoxStyle.Critical)
End If
Next
I have tried to put this under the CellEndEdit where the MessageBox working but it's still allow to move to next row. I also tried to put this code under CellValidating but the MessageBox keep on poping until I terminate the program.
Thanks.