Dear Sir,
I'm trying to Check that DataGridView cells are empty or have a value of 0 except for different cells categories with VB.net.
So I want an exception for existing cell categories `goods` and `Accessories` can pass the code in the buttoncheck event.
I want to exclude for category `goods` and `Accessories` So when running the event in button then it can pass it try running my code then it will give a messagebox because for the category 'goods' and 'accessories' there is a value of 0.
Please Guide me
Thanks
Public Class Form1
Private _list As New List(Of item)()
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
_list.Add(New item("1000", "goods", 2, 1, 0))
_list.Add(New item("1001", "Equipment", 1, 1, 1))
_list.Add(New item("1002", "Accessories", 2, 1, 0))
_list.Add(New item("1003", "machine", 1, 1, 1))
DataGridView1.DataSource = _list
End Sub
Private Sub buttoncheck_Click(sender As Object, e As EventArgs) Handles buttoncheck.Click
For Each row As DataGridViewRow In Me.DataGridView1.Rows
Dim i As Integer = 0
Do While (i < row.Cells.Count)
If row.Cells(i).Value Is Nothing OrElse IsDBNull(row.Cells(i).Value) _
OrElse String.IsNullOrEmpty(row.Cells(i).Value.ToString()) _
OrElse row.Cells(i).Value.ToString() = "0" Then
MessageBox.Show("cannot be empty and value 0...")
Return
End If
i = (i + 1)
Loop
Next
End Sub
End Class
Public Class item
Public Property codeproduct As String
Public Property category As String
Public Property qoh As Integer
Public Property qty As Integer
Public Property qtyreturn As Integer
Public Sub New(v1 As String, v2 As String, v3 As Integer, v4 As Integer, v5 As Integer)
Me.codeproduct = v1
Me.category = v2
Me.qoh = v3
Me.qty = v4
Me.qtyreturn = v5
End Sub
End Class