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

datagridview checkbox

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 checkboxes dont seem to work, and the datagridview throws a
dataerror when I try to leave the cell after trying to check/uncheck
the checkbox?!

Anyone know why this might be happening?

Thanks,

Peter

Sep 7 '07 #1
2 4261
On Sep 7, 12:22 pm, mrstrong <p.str...@gmail.comwrote:
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 checkboxes dont seem to work, and the datagridview throws a
dataerror when I try to leave the cell after trying to check/uncheck
the checkbox?!
Ok - on further investigation - it seems to be that when the
datagridview has EditMode=EditOnEnter, and when I go to add a new row
by clicking on one of the checkboxes, for some reason it is setting
the 'EditedFormattedValue' of the checkbox that I clicked on for the
new row to be the first value of the comboxbox that is the first
column in the datagridview. This is what's causing the dataerrors -
the checkbox's 'EditedFormattedValue' is getting set to a string
value, where it can only take a boolean.

Try setting up a datagridview with a combobox as the first column, and
a checkbox as the second column, and see if you get the same thing
when you go to add a new row by clicking on the checkbox.

Thanks,

Peter

Sep 12 '07 #2
On Sep 12, 12:17 pm, mrstrong <p.str...@gmail.comwrote:
On Sep 7, 12:22 pm, mrstrong <p.str...@gmail.comwrote:
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 checkboxes dont seem to work, and the datagridview throws a
dataerror when I try to leave the cell after trying to check/uncheck
the checkbox?!

Ok - on further investigation - it seems to be that when the
datagridview has EditMode=EditOnEnter, and when I go to add a new row
by clicking on one of the checkboxes, for some reason it is setting
the 'EditedFormattedValue' of the checkbox that I clicked on for the
new row to be the first value of the comboxbox that is the first
column in the datagridview. This is what's causing the dataerrors -
the checkbox's 'EditedFormattedValue' is getting set to a string
value, where it can only take a boolean.

Try setting up a datagridview with a combobox as the first column, and
a checkbox as the second column, and see if you get the same thing
when you go to add a new row by clicking on the checkbox.
Hmmm...I actually tried a blank project, added a
datagridview with two columns - one a combo box and the other a
checkbox and it worked perfectly...

I have a method attached to the datagridview for
defaultValuesNeeded, so mabye this was actually causing something
screwy to happen
here...

I have resolved to use the cellenter method of the
datagridview and call 'SendKeys.Send("{F4}");' if the cell is a combo
and this gives the desired action that the combo will dropdown when it
is first clicked (this is with editmode set back to its default value
of 'EditOnKeystrokeOrF2'). The checkboxes now behave as expected.

I originally had issues with sendkeys, as if you clicked on a
dropdown in to add a new row, and held down the mouse it would keep on
adding new rows. So I added this code in the cellenter method which
seemed to stop this
happening:

dgv.AllowUserToAddRows = false;
dgv.AllowUserToAddRows = true;

More than one way to skin a cat...

When I get time I'll go back and try to see if the defaultValuesNeeded
method might be causing any issues (currently the datatable it is
bound to has some required fields).

Thanks for your assistance.

Regards,

Peter

Sep 24 '07 #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, 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...
0
by: tramesh2007 | last post by:
I am using datagridviewcheckbox column in datagridview. I have a probelm for clicking checkbox column. The problem is, On datagrid_CellMouseClick event, for clicking checkbox when getting...
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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...
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...

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.