|
-
Dec 12th, 2008, 09:34 PM
#1
Re: CheckBox Question
What you're asking for suggests a design flaw. If the CheckBoxes are displaying an indeterminate state then that means that the values they are bound to are not True or False but null. If you don't want your CheckBoxes to indicate the existence of null values then why do you have null values in the first place? Why does it make sense for the database to contain null values if it doesn't make sense for the application to show these null values.
I really think that you need to address this. I would think that you need to change your database schema to disallow nulls in those columns and then you need to make sure that any new records always have a value in those columns, either by setting them explicitly EVERY time or else by setting a default value on the columns.
Now, CheckBoxes can only display an indeterminate state if you have their ThreeState property set to True. Presumably you have dragged these columns from the Data Sources window to create the CheckBoxes. The reason that their ThreeState property has been set to True is SPECIFICALLY so that they can indicate that the bound value is not True or False.
-
Dec 13th, 2008, 01:19 AM
#2
Thread Starter
Lively Member
Re: CheckBox Question
thanks for the reply first of all. i understand what you mean. i went into the dataset designer and changed the default values (which were null) to a value of 0 (false). Thanks, it works!
Last edited by new2visualBasic; Dec 13th, 2008 at 01:23 AM.
-
Dec 13th, 2008, 01:33 AM
#3
Re: CheckBox Question
 Originally Posted by new2visualBasic
thanks for the reply first of all. the problem occurs when i add a new row to the dataset using bindingSource.AddNew(). The form shows the checkboxes in this state. The problem does not occur else where.
You already have the solution. Go into the database and change the properties of those columns to not allow nulls and have a default value False (or 0 if it's a bit column I think). Those properties are then propagated to your DataTable. That way, when you create a new row those columns will contain False by default and your CheckBoxes will be unchecked.
Note that, if you're using a typed DataSet, you'll need to reconfigure your Data Source after changing the database schema in order to update the DataSet schema.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|