G
Gary Shell
I have a pair of combo boxes on a form. Both have their SelectedValue
property bound to a column on a table called "Input_Output". One column is
called "Class" and the second is called "SubClass". Each combobox has its
datasource, displaymember and SelectedValue member bound to separate tables
thru individual datatsets thru individual data adapters. The two tables are
"Class" and "SubClass".
I use parameterized query to populate the list portion of the SubClass Combo
box based on the selection displayed in the Class combobox. When editing
existing records everything works just fine. I can select a new Class and
the SubClass combobox list content changes as expected. The text displayed
in the SubClass combo changes to the first item in the list, EVEN IF NO
SELECTION IS MADE IN THE SUBCLASS COMBO. Updates to the data adapter
successfully update the database. So far so good.
If I attempt to ADD a new record, I have trouble. Initially the Class combo
and SubClass comboboxes are blank. Selecting an item in the Class combo
cause the SubClass combobox to be repopulated, with the first entry
displayed. When I execute the following code the SubClass combobox
immediately goes blank:
Me.BindingContext(Me.DsInput_Output, "Input_Output").EndCurrentEdit()
If DsInput_Output.HasChanges(DataRowState.Added) Then
'only if there really are adds to be processed
sqldaInput_Output.Update(Me.DsInput_Output)
strTheItem = Me.cmbIO_Name.Text
End If
The SubClass combo actually goes blank on the EndCurrentEdit method. So, of
course, the database gets a null for that column when the Update method is
executed. If I set a breakpoint on the EndCurrentEdit I can see that the
SubClass combo box TEXT, and SELECTEDVALUE properties both have the expected
string value. After the EndCurrentEdit they are NOTHING.
Now the strange part. If I actually select an item in the SubCLass combo the
EndCurrentEdit and subsequent code work just fine. Why is this explicit
selection necessary? Why is the EndCurrentEdit setting the SelectedValue
property to nothing? I'm confused and frustrated.
Google searches have turned up little, except to note that apparently the
combobox is a bit buggy. Specifically when placed on a tab page. (And you
guessed it, I am using these on a tab page. Sigh.)
Anyone else fought this battle? Anyone win? Should I just use a third
party combobox and cut my losses?
Thanks,
Gary
property bound to a column on a table called "Input_Output". One column is
called "Class" and the second is called "SubClass". Each combobox has its
datasource, displaymember and SelectedValue member bound to separate tables
thru individual datatsets thru individual data adapters. The two tables are
"Class" and "SubClass".
I use parameterized query to populate the list portion of the SubClass Combo
box based on the selection displayed in the Class combobox. When editing
existing records everything works just fine. I can select a new Class and
the SubClass combobox list content changes as expected. The text displayed
in the SubClass combo changes to the first item in the list, EVEN IF NO
SELECTION IS MADE IN THE SUBCLASS COMBO. Updates to the data adapter
successfully update the database. So far so good.
If I attempt to ADD a new record, I have trouble. Initially the Class combo
and SubClass comboboxes are blank. Selecting an item in the Class combo
cause the SubClass combobox to be repopulated, with the first entry
displayed. When I execute the following code the SubClass combobox
immediately goes blank:
Me.BindingContext(Me.DsInput_Output, "Input_Output").EndCurrentEdit()
If DsInput_Output.HasChanges(DataRowState.Added) Then
'only if there really are adds to be processed
sqldaInput_Output.Update(Me.DsInput_Output)
strTheItem = Me.cmbIO_Name.Text
End If
The SubClass combo actually goes blank on the EndCurrentEdit method. So, of
course, the database gets a null for that column when the Update method is
executed. If I set a breakpoint on the EndCurrentEdit I can see that the
SubClass combo box TEXT, and SELECTEDVALUE properties both have the expected
string value. After the EndCurrentEdit they are NOTHING.
Now the strange part. If I actually select an item in the SubCLass combo the
EndCurrentEdit and subsequent code work just fine. Why is this explicit
selection necessary? Why is the EndCurrentEdit setting the SelectedValue
property to nothing? I'm confused and frustrated.
Google searches have turned up little, except to note that apparently the
combobox is a bit buggy. Specifically when placed on a tab page. (And you
guessed it, I am using these on a tab page. Sigh.)
Anyone else fought this battle? Anyone win? Should I just use a third
party combobox and cut my losses?
Thanks,
Gary