Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / September 2007

Tip: Looking for answers? Try searching our database.

datagridview checkbox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mrstrong - 07 Sep 2007 03:22 GMT
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
mrstrong - 12 Sep 2007 03:17 GMT
> Gday,
>
[quoted text clipped - 5 lines]
> 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
mrstrong - 24 Sep 2007 02:55 GMT
> > Gday,
>
[quoted text clipped - 18 lines]
> 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.