Dear Sir,
I'm Trying to check whether checkbox without checked in datagridview column in event button with vb.net.
So I want if the user only does 1 checkbox that is enough or several checkbox then the messagebox will not appear unless there is no checked at all then the messagebox appears when in event button ("Btncheckforcheckboxdgvunchec")
I tried it in the event button ("Btncheckforcheckboxdgvunchec")
Not successful messagebox won't appear if I checkbox all
Please Guide me
Thanks
Imports System.Globalization
Public Class Form2
Private OrderDetail As List(Of OrderDetail)
Private bindingSource As BindingSource = Nothing
Private _criteriasBindingList As New SortableBindingList(Of OrderDetail)()
Public Sub New()
InitializeComponent()
Dim CheckedBoxColumn As New DataGridViewCheckBoxColumn
CheckedBoxColumn.Width = 40
CheckedBoxColumn.Name = "checkboxcolumn"
CheckedBoxColumn.HeaderText = "Check"
CheckedBoxColumn.ReadOnly = False
DataGridView1.Columns.Insert(0, CheckedBoxColumn)
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.LoadData()
End Sub
Private Sub LoadData()
OrderDetail = New List(Of OrderDetail) From {
New OrderDetail() With {
.Invono = "PI0001",
.InvoDate = Convert.ToDateTime("06-05-2024"),
.Days = Convert.ToDateTime("06-05-2024").ToString("dddd"),
.ProductName = "TEST 1000",
.UnitPrice = 15000,
.Quantity = 20
},
New OrderDetail() With {
.Invono = "PI0002",
.InvoDate = Convert.ToDateTime("07-05-2024"),
.Days = Convert.ToDateTime("07-05-2024").ToString("dddd"),
.ProductName = "TEST 2000",
.UnitPrice = 25000,
.Quantity = 20
},
New OrderDetail() With {
.Invono = "PI0003",
.InvoDate = Convert.ToDateTime("06-05-2024"),
.Days = Convert.ToDateTime("06-05-2024").ToString("dddd"),
.ProductName = "TEST 3000",
.UnitPrice = 17000,
.Quantity = 20
},
New OrderDetail() With {
.Invono = "PI0004",
.InvoDate = Convert.ToDateTime("07-05-2024"),
.Days = Convert.ToDateTime("07-05-2024").ToString("dddd"),
.ProductName = "TEST 4000",
.UnitPrice = 18000,
.Quantity = 20
}
}
_criteriasBindingList = New SortableBindingList(Of OrderDetail)(OrderDetail)
bindingSource = New BindingSource With {.DataSource = _criteriasBindingList}
DataGridView1.DataSource = bindingSource
End Sub
Private Sub Btncheckforcheckboxdgvunchec_Click(sender As Object, e As EventArgs) Handles Btncheckforcheckboxdgvunchec.Click
For Each row As DataGridViewRow In DataGridView1.Rows
Dim cell As DataGridViewCheckBoxCell = TryCast(row.Cells("checkboxcolumn"), DataGridViewCheckBoxCell)
If cell.Value Is cell.TrueValue Then
MessageBox.Show("checkboxcolumn must be checked")
Return
End If
Next row
End Sub
End Class
Public Class OrderDetail
Public Property Invono As String
Public Property InvoDate As DateTime
Public Property Days As String
Public Property ProductName As String
Public Property UnitPrice As Integer
Public Property Quantity As Integer
End Class