Default Unchecked Checkbox has colored box with new record

larkahn

Member
Joined
Sep 10, 2006
Messages
18
Programming Experience
1-3
Default Unchecked Checkbox has colored box with new record [RESOLVED]

With a minimum amount of coding, I have some checkboxes on a form bound to an Access database set so that the default value is unchecked. Yet, whenever a new record is created, the checkbox initially has a colored square inside it. It is neither checked nor unchecked. Even if when I click to create a new record I set the checked state to false, the colored square shows up. If I click on the checkbox when the program is running, there is no problem. I can either click to make the check mark appear or clear the colored square.

The only crude way I've been able to have a clean checkbox is that when a new record is created, I set the focus to the check box and use
VB.NET:
SendKeys.send (" ")
to enter a space which clears the box.

If when creating a new record by clicking on a button, I enter code
VB.NET:
mycheckbox.checked = false
, the checkbox in the new record still appears with the colored box. Can someone explain why the colored box appears and if there is a more elegant way to make sure that it is cleared? I'm a low level programmer.
 
Last edited:
The state of that check box reflects the data that it's bound to. If the field it's bound to is null then the check box will show that indeterminate state. If you want the check box to be unchecked then you obviously want the field it's bound to to be False, so that's exactly what you should do. Set the DefaultValue of the DataColumn, i.e. the column in the DataTable, that that check box column is bound to to False. Then when you create a new record that field will be False by default and the check box will be unchecked.
 
Unfortunately it doesn't usually show up in the thread listing but you can edit the title of the thread and add [RESOLVED] or the like to indicate to those who view the thread at least.
 
Back
Top