473,414 Members | 1,675 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

DataGridView checkbox scan?

foreach (DataGridViewRow row in this.dataGridView.Rows)
{

if (row.Cells[0].Value.ToString() == "true")
{
return true;

}
}
return false;
I try in a if senctens to scan a datagridview cell but how to test the
checkbox cell I have look for som in books an on the inetenet but not found
somehing.

Best regard
Kim
Jul 2 '08 #1
2 2131
On Jul 2, 4:16*am, Kim <K...@discussions.microsoft.comwrote:
* * * *foreach (DataGridViewRow row in this.dataGridView.Rows)
* * * *{

* * * * * * * * if (row.Cells[0].Value.ToString() == "true")
* * * * * * * * {
* * * * * * * * * *return true;

* * * * * * * * }
* * * *}
return false;

I try in a if senctens to scan a datagridview cell but how to test the
checkbox cell I have look for som in books an on the inetenet but not found
somehing.

Best regard
Kim
Verify that the cell is of type DataGridViewCheckBoxCell first...
You also might want to verify that the
DataGridViewCheckBoxCell.TrueValue is not null since it's an object
and not a boolean data type.

foreach (DataGridViewRow row in dataGridView.Rows)
{
if (!row.IsNewRow)
{
if (row.Cells[0].GetType() ==
typeof(DataGridViewCheckBoxCell))
{
if ((bool)
(((DataGridViewCheckBoxCell)row.Cells[0]).TrueValue))
{
return true;
}
}
}
}

Cheers
Greg
Jul 2 '08 #2


"Greg" wrote:
On Jul 2, 4:16 am, Kim <K...@discussions.microsoft.comwrote:
foreach (DataGridViewRow row in this.dataGridView.Rows)
{

if (row.Cells[0].Value.ToString() == "true")
{
return true;

}
}
return false;

I try in a if senctens to scan a datagridview cell but how to test the
checkbox cell I have look for som in books an on the inetenet but not found
somehing.

Best regard
Kim

Verify that the cell is of type DataGridViewCheckBoxCell first...
You also might want to verify that the
DataGridViewCheckBoxCell.TrueValue is not null since it's an object
and not a boolean data type.

foreach (DataGridViewRow row in dataGridView.Rows)
{
if (!row.IsNewRow)
{
if (row.Cells[0].GetType() ==
typeof(DataGridViewCheckBoxCell))
{
if ((bool)
(((DataGridViewCheckBoxCell)row.Cells[0]).TrueValue))
{
return true;
}
}
}
}

Cheers
Greg

Tanks but I just cast by (bool)row.Cells[0].Value == true for the cell
Jul 3 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rick Shaw | last post by:
Hi, I have a problem with the datagridview not refreshed when the application first appear on the screen. The datagridview display data from a table in the dataset. At the same time, I've added...
4
by: Hexman | last post by:
Hello All, I'd like to find out the best way to add a cb column to a dgv and process efficiently. I see at least two ways of doing it. ------------------------------- 1) Add a cb to the dgv,...
4
by: Annie | last post by:
hello guys, I am having a DataGridView control. The first column is a checkbox column. The users can select the checkbox column. I need to loop through the grid rows and get the checked...
2
by: mrstrong | last post by:
Gday, I have a datagridview that I am creating the columns programatically which all seems to work fine. I have a couple of dropdown boxes, so I have set the editMode= EditOnEnter. Now my...
2
by: mrstrong | last post by:
Gday, Why would all my checkboxes inside a datagridview stop working (ie checked state not updating when user clicks) when the datagridview's editmode property is changed to "EditOnEnter"? It...
1
by: zacks | last post by:
Using VS 2005. I have an app that has a DataGridView control. This control has two columns, the first column is a standard TextBox, and the second column is a CheckBox. I am having difficulty...
1
by: QuickBooksDev | last post by:
VB.NET 2005 DataGridView Checkbox - Check Event need to know check status I would like to use the DataGridView Checkbox like a normal checkbox. When someone clicks on it I would expect that I...
8
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
If I populate a DataGridView with a query supplied at runtime, boolean fields render as a CheckBox instead of just a text rendering of '0' or '1'. That is nice sometimes, but I would like the...
0
by: =?Utf-8?B?S2lt?= | last post by:
Hi all I'm working with a column of checkbox in datagridview. I can mark the cells defalut false 1. time by set thristate to false and varpmode to false too => all the cell are default false...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.