---
title: "Selecting checkbox inside datagridview c#"  
description: "Selecting checkbox inside datagridview c#"  
author: "Anonymous User"  
published: 2014-03-29  
updated: 2014-03-29  
canonical: https://www.mindstick.com/forum/2003/selecting-checkbox-inside-datagridview-c-sharp  
category: "asp.net mvc"  
tags: ["asp.net mvc"]  
reading_time: 2 minutes  

---

# Selecting checkbox inside datagridview c#

I have a dowpdownlist, a [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) and a [checkbox](https://www.mindstick.com/articles/291/how-should-use-checkbox-control-in-vb-dot-net) inside the datagridview.

I just only manually created a [check](https://yourviews.mindstick.com/story/2248/never-forget-to-check-these-specifications-before-buying-a-mobile-phone) box [column](https://www.mindstick.com/forum/33860/how-to-calculate-column-summary-in-sql-server) on the datagridview. (here is the [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii))

[DataGridViewCheckBoxColumn](https://www.mindstick.com/forum/368/datagridviewcheckboxcolumn) CheckboxColumn = new DataGridViewCheckBoxColumn();

CheckBox chk = new CheckBox();

CheckboxColumn.Width = 20;

DataGrid1.Columns.Add(CheckboxColumn);

here is the procedure.

step 1: the [user](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) will [choose](https://www.mindstick.com/articles/13030/how-to-choose-the-best-online-bitcoin-casino) item on the checkbox.

step 2: the user will choose item on the dropdown.

Step 3: the user will [click](https://www.mindstick.com/articles/12423/social-login-magento-2-one-click-to-register-social) on the button and it will change the itemname

on the checkbox prior to the item selected on the dropdownlist.

here is my [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) after clicking on the button, nothings happen.

here is my code.

```
private void button1_Click(object sender, EventArgs e)        {    int x = 0;                foreach (DataGridViewRow item in this.DataGrid1.SelectedRows)                {                    DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)item.Cells[1];                    if (chk.Selected)                    {                    // codes here                    }                    else                    {                    //code here                    }                }                x = x + 1;         }
```

## Replies

### Reply by Pravesh Singh

Hi Jacob,

```
private void button1_Click(object sender, EventArgs e){    int x = 0;    foreach (DataGridViewRow item in this.DataGrid1.SelectedRows)    {       
DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)item.Cells[1];        if (chk.Value)        {              // codes here for checked condition        }        else        {              //code here  for UN-checked condition        }      }     x = x + 1; }
```


---

Original Source: https://www.mindstick.com/forum/2003/selecting-checkbox-inside-datagridview-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
