DataGridView Checkbox threestate

SteveW

Member
Joined
Jul 11, 2006
Messages
6
Location
New Jersey
Programming Experience
Beginner
I have a problem using checkboxes in DataGridView.

I created a datatable having one column declared as CheckState and initialized from other application info with a state.

A DataGridView created in a form was then bound to this table. All the checkboxes look great and have the correct values. The user can click on them to change their state.

However, when the user clicks on a checkbox, it sequentially passes through all three possible checkbox states - unchecked, checked and indeterminate. I want to eliminate the indeterminate state so it just flips back and forth between checked and unchecked.

This requires that the Threestate property for the checkboxes be set to False. I cannot for the life of me figure out how to do that.

Sample code would be very appreciated!

Thanks!

Steve...
 
Get the checkbox column by index or name, then cast it into the type DataGridViewCheckBoxColumn to access the ThreeState property and set its value to False. This works, but it is a bit strange to have to do this because the default ThreeState value is already False. When databinding I've seen its value is True by default, so you haven't done anything wrong :)
VB.NET:
DirectCast(DataGridView1.Columns("checkboxcolumn"), DataGridViewCheckBoxColumn).ThreeState = False
 
Back
Top