Rabu, 30 Maret 2016

VB.NET - How To Check If DataGridViewCheckBoxCell Is Checked In VB NET

vb datagridview check box


C# - How To Know If DataGridViewCheckBoxCell Is Checked In C#

                                                                                                                         

In This VB.NET Tutorial  We Will See How To Check If DataGridView CheckBox Cell Is Checked Or Not In VBNET Programming Language.


Project Source Code:

Public Class VB_DataGridView_CheckBoxCell_Checked

    Private Sub VB_DataGridView_CheckBoxCell_Checked_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        ' add some row to datagridview
        ' true the checkBox Is checked
        ' false the checkBox Is Not checked
        Dim CheckBoxColumn As New DataGridViewCheckBoxColumn()
        CheckBoxColumn.HeaderText = "Check Box Column"
        DataGridView1.Columns.Add(CheckBoxColumn)
        DataGridView1.Rows.Add(False)
        DataGridView1.Rows.Add(False)
        DataGridView1.Rows.Add(False)
        DataGridView1.Rows.Add(False)
        DataGridView1.Rows.Add(False)
        DataGridView1.Rows.Add(False)
        DataGridView1.Rows.Add(False)
        DataGridView1.Rows.Add(False)
        DataGridView1.Rows.Add(False)
        DataGridView1.Rows.Add(False)
        DataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
        DataGridView1.AllowUserToAddRows = False

    End Sub

    Private Sub BtnCheckedCell_Click(sender As Object, e As EventArgs) Handles BtnCheckedCell.Click

        For i As Integer = 0 To DataGridView1.Rows.Count() - 1
            Dim c As Boolean
            c = DataGridView1.Rows(i).Cells(0).Value
            ' if the checkbox cell is checked
            If c = True Then
                MessageBox.Show("Checked")
                ' if not
            Else
                MessageBox.Show("Not Checked")
            End If
        Next

    End Sub
End Class
      
///////////////OUTPUT:


vb datagridview check box checked
vb datagridview checkbox cell checked

Bagikan

Jangan lewatkan

VB.NET - How To Check If DataGridViewCheckBoxCell Is Checked In VB NET
4/ 5
Oleh

Subscribe via email

Suka dengan artikel di atas? Tambahkan email Anda untuk berlangganan.