The Access data type to represent a Boolean is `Yes/No`. Yes corresponds to True and No corresponds to False, as you'd expect. In .NET, the CheckBox property that represents a Boolean is Checked, NOT CheckState. I see so many people using CheckState without ever reading anything about it to see what it is really for.
You use CheckState ONLY if you want a tri-state CheckBox, i.e. one that can be checked, not checked or in an indeterminate state. You would use that to represent a nullable Boolean. If you have a yes/No column in Access that supports NULLs then you would use the CheckState, i.e. Yes corresponds to Checked, No corresponds to Unchecked and NULL corresponds to Indeterminate.
So, you should NEVER be assigning values from an Access field directly to the CheckState property. If the field is not nullable then it should contain a Boolean and that should be assigned to the Checked property.If it is nullable then it should still contain Booleans so you first test whether it does and then which it is and assign the appropriate CheckState value.Code:myCheckBox.Checked = CBool(myDataRow("YesNoColumn"))Code:myCheckBox.CheckState = If(myDataRow.IsNull("YesNoColumn"), CheckState.Indeterminate, If(CBool(myDataRow("YesNoColumn")), CheckState.Checked, CheckState.Unchecked))




Reply With Quote
