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 8252187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:29:31+00:00 2026-06-08T00:29:31+00:00

I want to get a checkbox value from a datagridview(True/False) but I always get

  • 0

I want to get a checkbox value from a datagridview(True/False) but I always get a value “null”, here is the code where i get the value of the checkbox:

DataGridViewCheckBoxCell boolean = (DataGridViewCheckBoxCell)dgv[e.ColumnIndex, e.RowIndex];
string checkCheckboxChecked = ((bool)boolean.FormattedValue) ? "False" : "True";

This code returns a false in the Boolean.FormattedValue even the checkbox is checked
and also I tried another:

object value = dgvVisual[e.ColumnIndex, e.RowIndex].Value;

And this code return a value of null

Why does this happen?

P.S. e is an event of the CELL CONTENT CLICK.

Here is the full code of the datagridview cell content click:

private void dgvVisual_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
    int Number1= int.Parse(dgvVisual[0, e.RowIndex].Value.ToString());
    int Number2 = (e.ColumnIndex - 1);                
    DataGridViewCheckBoxCell boolean = (DataGridViewCheckBoxCell)dgvVisual[e.ColumnIndex, e.RowIndex];
    bool checkCheckboxChecked = (null != boolean && null != boolean.Value && true == (bool)boolean.Value);
    //string checkCheckboxChecked = "";
    if (checkCheckboxChecked)
    {
        //do something if the checkbox is checked
    }
    else
    {
        //do something if the checkbox isn't
    }
}

SOLVED:
I changed the CELL END EDIT EVENT and add the click content to datagridview.CurrentCell to another cell.

  • 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-08T00:29:33+00:00Added an answer on June 8, 2026 at 12:29 am

    Its a bit odd calling the cell boolean. And then using its FormattedValue property. I added a DataGridView to a Form, added two columns Text and Checkbox. CheckBox is a DataGridViewCheckBoxColumn. Then I added a button and this should give you the idea:

    private void button1_Click(object sender, EventArgs e)
    {
        dgv.AutoGenerateColumns = false;
        DataTable dt = new DataTable();
        dt.Columns.Add("Text");
        dt.Columns.Add("CheckBox");
        for (int i = 0; i < 3; i++)
        {
            DataRow dr = dt.NewRow();
            dr[0] = i.ToString();
            dt.Rows.Add(dr);
        }
        dgv.DataSource = dt;            
    }
    
    private void dgv_CellEndEdit(object sender, DataGridViewCellEventArgs e)
    {
        foreach (DataGridViewRow row in dgv.Rows)
        {
            var oCell = row.Cells[1] as DataGridViewCheckBoxCell;
            bool bChecked = (null != oCell && null != oCell.Value && true == (bool)oCell.Value);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What I want: get a xml from the AppData to use What I code
I'm using a method as explained here: http://iamcam.wordpress.com/2008/01/15/unchecked-checkbox-values/ to get a value even if
When I click a button I want to get the value from each of
am having a set of checkbox in a stackpanel, i want to get the
I want get as much as possible from Redis + Hiredis + libevent. I'm
Basically I want get data I already have accessed from javascript and passing it
I want to get 100 and example from this string ?connect:100/username:example/ I searched in
I have a check box and want to get the very inital value or
I have a checkbox, how do I get its value using jquery? I have
i want insert this form value to datanase : <input type=checkbox name=brand1 id=brand1 value=1>

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.