Setting value of datagridviewcheckboxcell

D

Diane Yocom

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
 
D

Diane Yocom

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?
 
D

Diane Yocom

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top