Results 1 to 5 of 5

Thread: [RESOLVED] CheckBox Question

Hybrid View

  1. #1
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Jul 2008
    Posts
    92

    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.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: CheckBox Question

    Quote 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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width