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 / Windows Forms / WinForm General / September 2006

Tip: Looking for answers? Try searching our database.

Setting value of datagridviewcheckboxcell

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Diane Yocom - 29 Sep 2006 16:55 GMT
I have a datagridview with a datagridviewcheckboxcolumn.  The datagridview
is bound to a custom collection.  The DGV, itself, is loading fine, but I
cannot seem to figure out how to programmatically set whether or not the
checkbox is checked.

I've tried the following:
row.Cells("colName").Value = true
ctype(row.Cells("colName"), DataGridViewCheckBoxCell).Value = True

I've tried changing the value in the DataBindingComplete event.  I've tried
unbinding the grid and just setting the value as I'm adding rows to the row
collection.  Nothing seems to work.  I can watch it step right over the line
of code in the debugger and the value doesn't change at all...it just stays
at Nothing.

Any help would be much appreciated!
Diane
Diane Yocom - 29 Sep 2006 18:15 GMT
I've got some more information on the issue.  I can set the checkbox to
checked if I set the DataPropertyName for the checkbox column.  This doesn't
work for me, though.  I *want* this to be an unbound column and to control
the value at runtime.  Plus, how on earth would you use this in an unbound
datagrid if the column has to be bound?

>I have a datagridview with a datagridviewcheckboxcolumn.  The datagridview
>is bound to a custom collection.  The DGV, itself, is loading fine, but I
[quoted text clipped - 13 lines]
> Any help would be much appreciated!
> Diane
Diane Yocom - 29 Sep 2006 22:01 GMT
For anyone who is having a similar problem, I figured it out:

I was setting VirtualMode to true.  When I set it to false, my code below
worked fine.

Apparently you can't edit the value of columns in VirtualMode?

> I've got some more information on the issue.  I can set the checkbox to
> checked if I set the DataPropertyName for the checkbox column.  This
[quoted text clipped - 19 lines]
>> Any help would be much appreciated!
>> Diane

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.