Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15015

[RESOLVED] Datagrid validation in vb. (if statement)

$
0
0
I have a datagrid with several columns, the first column is the release column. This column validate that the release is valid and validate that the release is in another table.

I have two private functions that help with the validation: Private Function CheckSatus(strRelease As String) As Boolean and Private Function CheckRelease(strRelease As String) As Boolean

What is currently happening:
When you enter an invalid release it turns the back color yellow.

What is expected:

It should hit the CheckSatus(chkValue) and turn back color red and stop.

Here is the code I currently have:

Private Sub gridUserEntries_CellLeave(sender As Object, e As DataGridViewCellEventArgs) Handles gridUserEntries.CellLeave
If (e.ColumnIndex = 0) Then
Dim currCell As DataGridViewCell = gridUserEntries.CurrentCell
Dim chkValue As String = currCell.GetEditedFormattedValue(currCell.RowIndex, DataGridViewDataErrorContexts.Display)

If Not (chkValue.Trim = "") Then
'Validate if release is in jobscopedb.IPJOBM table
If CheckSatus(chkValue) Then
currCell.Style.BackColor = Color.White
Else
currCell.Style.BackColor = Color.Red
btnUpdatePPUSRFS.Enabled = False
btnClear.Enabled = True
End If
'Validate if the Release Number is in the PPUSRFS TABLE
If CheckRelease(chkValue) Then
currCell.Style.BackColor = Color.White
btnValidate.Enabled = True
btnRetrieve.Enabled = True
btnClear.Enabled = True
Else
currCell.Style.BackColor = Color.Yellow
btnInsertPPUSRFS.Enabled = True
btnValidate.Enabled = False
btnRetrieve.Enabled = False
End If
Else
currCell.Style.BackColor = Color.White
End If

End If

Viewing all articles
Browse latest Browse all 15015

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>