Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8185397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:50:04+00:00 2026-06-07T01:50:04+00:00

I have a DataGridView which contains a DataGridViewColumn and also a button. When I

  • 0

I have a DataGridView which contains a DataGridViewColumn and also a button. When I click the button I want to check if all checkboxes in the datagridview are checked or not.

I use the following code but it is not working:

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    For i As Integer = 0 To DataGridView1.Rows.Count - 1
        Dim CheckBox As DataGridViewCheckBoxCell = DirectCast(DataGridView1.Rows(i).Cells(0), DataGridViewCheckBoxCell)
        If Not CheckBox.Value = Not CheckBox.Value Then
            MsgBox("True")
        End If
    Next
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T01:50:06+00:00Added an answer on June 7, 2026 at 1:50 am

    I can’t really tell what your logic is supposed to be doing with this line:

    If Not CheckBox.Value = Not CheckBox.Value Then

    It looks like you are saying, “if Not Value = Not Value” ???

    Try this:

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
      For i As Integer = 0 To DataGridView1.Rows.Count - 1
        'Dim CheckBox As DataGridViewCheckBoxCell = DirectCast(DataGridView1.Rows(i).Cells(0), DataGridViewCheckBoxCell)
        'If Not CheckBox.Value = Not CheckBox.Value Then
        '  MsgBox("True")
        'End If
        Dim obj As Object = DataGridView1.Rows(i).Cells(0)
        If (Not obj Is Nothing) Then
          Dim checkBox1 As DataGridViewCheckBoxCell = DirectCast(obj, DataGridViewCheckBoxCell)
          Dim objValue As Object = checkBox1.Value
          If (Not objValue Is Nothing) Then
            Dim checked As Boolean = DirectCast(objValue, Boolean)
            If (checked) Then
              MsgBox("True")
            End If
          End If
        End If
      Next
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a datagridview in which one column contains a custom class, which I
I have a dataGrid(not dataGridView) in which i need to add Checkbox dynamically at
I have a form which contains 2 buttons , a datetimepicker and datagridview which
I have a form which contains a DataGridView, a BindingSource, a DataTable, and a
I have a datagridview with a bound combobox column which contains decimal value. There
I have a MDI Child Form which contains a DataGridView that is updated continuously
I have a DataGridView which is bound to a DataTable that contains a column
I have a DataGridView which is data-bound to a BindingList. My DataGridView also has
I have a datagridview which im binding DataTable to. What I want do is
I have a datagridview which is used for listing all the students information .I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.