将值表单Textbox传递到DataGridView时,如何验证DataGridView行详细信息是否已经存在?
这是我的功能:argAccount
&argPortfolio
是文本框值
Function fnValidateAccountPortfolio(ByVal argAccount As String, ByVal
argPortfolio As String) As Boolean
Try
For Each row As DataGridViewRow In Form1.DataGridView1.Rows
If Not row.IsNewRow Then
MessageBox.Show(row.Cells(0).Value.ToString & " Is Already
Exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
Next
Catch ex As Exception
Exit Function
End Try
End Function
Private Sub BtnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Handles BtnSave.Click
If fnValidateAccountPortfolio(txtAccount.Text, txtPortfolio.Text) = False
Then
MessageBox.Show("Successfully Saved", "Save", MessageBoxButtons.OK,
MessageBoxIcon.Information)
End If
end sub