none
Bound CheckBox Default State

    Question

  • I am currently stumped on setting a databound checkbox control checkedstate, or checked property on new records. None of the below will work as I would expect. Any ideas? The column "Active" is TinyInt(1) and I need it to default to 1 (true) upon adding new records. I've tried handeling it from the binding navigator adding new method as well with the same nonresult.

        Private Sub AddNewPart() Handles PartsBS.AddingNew
            chk_active.Checked = True
            chk_active.CheckState = CheckState.Checked
            PartsBS.Current("Active") = True
        End Sub


    Live as if you were going to die today, learn as if you were going to live forever -Mahatma Gandhi

    Thursday, March 16, 2017 2:52 PM

All replies

  • By setting the defaultvalue of the column in the datatable prior to initializing the bindingsource seems to do the trick

                    With PartsTable
                        .Columns("Active").DefaultValue = "1"
                    End With
                    PartsBS.DataSource = PartsTable

    At which point the checkbox databindingbinding handles the checkedstate and checked properties.


    Live as if you were going to die today, learn as if you were going to live forever -Mahatma Gandhi

    Thursday, March 16, 2017 3:31 PM