473,387 Members | 1,515 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,387 software developers and data experts.

Can't retrieve the value of a DataGridView Checkbox

4
Hi everyone.

I'm having a really annoying problem I can't solve and couldn't find an answer to anywhere, let's see if you got what it takes.

I have a dataGridView on a C# Windows Form. Unbound. I fill in rows with a button.

I have a checkbox column which isn't read-only (unlike the other columns) so the user could check whatever row he wants.

All I simply want is to know (on CellContentClick) if the checkbox is checked or not!

I do this for now:

Expand|Select|Wrap|Line Numbers
  1. private void dataGridView1_CellContentClick(object sender,DataGridViewCellEventArgs e)
  2.      {
  3. MessageBox.Show(dataGridView1[e.ColumnIndex, e.RowIndex].Value.ToString());
  4. }
It works for every other cell, but when clicking a checkbox, it fails and returns:
"Object reference not set to an instance of an object."
Why? Because the .Value = null.

Please please help!

Thanks alot in advance,
Ben.
Aug 22 '08 #1
4 2562
Benysh
4
OK!

Just managed pulling it off myself:

MessageBox.Show(dataGridView1[e.ColumnIndex, e.RowIndex].EditedFormattedValue.ToString());

Probably had something to do with if it's in Edit mode or not

Thanks alot! This forum is awesome!
Aug 22 '08 #2
kenobewan
4,871 Expert 4TB
Glad we could be of assistance ;). Well done!
Aug 23 '08 #3
Benysh
4
heh

thanks

though now I have something I didn't manage ;)

EditedFormattedValue seems to be readonly

How do I change the checkbox status? For example, on a button click, check/uncheck a certain checkbox cell

Well?

Thanksa
Aug 23 '08 #4
Benysh
4
*polite bumb*
Can anyone help with this?
Aug 29 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Angelos | last post by:
I have this list of logs stored in a MySQL DB. I display them in a list and next to each log I have a del view LINK I want to add Checkboxes next to each log and keep del and view links as...
8
by: Jack | last post by:
Hi, Here is my problem: I am logging in to a page, where the page retrieves a record from a database. The text boxes are used in the display formto let the users update the fields, if they...
1
by: michael schindler | last post by:
hi there i have tried do use the new DataGridView of the Framework 2.0. i use the new DataGridViewCheckBoxColumn Somehow i don't know how to read if a checkbox is checked or not. For example in...
3
by: niftyhawk | last post by:
Hi All, I have a php page say "abc.php" generating the following HTML. I am posting the form action to another php page say "TestCheckbox.php". How do I retrieve in "TestCheckbox.php" which...
3
by: sankarpulivarthi | last post by:
Hi i have a checkbox in first datagridview . when it is checked it should get that row values.and iam trying to display that checked row values in a second datagridview after clicking a button....
0
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 datagridviews editMode=...
6
by: dmorand | last post by:
I'm populating some checkboxes from a query result. I'm having a problem retrieving the data to file it to my database. How do I retrieve the checkbox values when the names are variable names? 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...
4
by: TechnoAtif | last post by:
Hi ALL I have entered some array values using checkboxes into mysql database through a form. Next iam creating a searchpage where all those cateogories inserted through checkboxes has to be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.