Data binding problems

  • Thread starter Thread starter Nathan
  • Start date Start date
N

Nathan

I have a form with combo boxes, text boxes, and radio buttons bound to a
dataset table (Students) taken from an Access database. The main control is
cboStudents, which lists all the students from the table. The Datasource,
Datamember, and Valuemember properties of cboStudents have been set
appropriately, and the Tag property is set to StudentID, the primary key on
the table. Then I bind the text property of the textboxes and comboboxes to
appropriate values, as well as the checked property of the radio buttons,
which are bound to boolean values in the dataset.

There is a Next button on the form, which moves to the next student. It's
click event has the following code:

With Me.BindingContext(Dataset, "Students")
If .Position > 0 Then
cboStudents.SelectedIndex = .Position - 1
ElseIf .Position = 0 Then
cboStudents.SelectedIndex = .Count - 1
End If
End With

Then this sub is subsequently called:

Private Sub cboStudents_Change(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cboStudents.SelectedIndexChanged
Me.BindingContext(datSPARK, "Students").Position =
cboStudents.SelectedIndex
End Sub

When I run the application, cboStudents is filled correctly, but the
application hangs on the above line (Me.BindingContext...) I cannot
manipulate any of the controls on the form, except cboStudents; and when I
click it, the box drops down and flickers a couple times, then the
application ends with an error message pointing to the above line.

If I remove the tag property of cboStudents, then everything works fine.
But I need the tag property set to the StudentID for other functions. I
have tried setting the tag property of the other controls, but that does not
help. I have tried restarting my computer. I have tried creating a brand
new database and from that creating a new oledb connection and a new dataset
with a new table, and I encounter the same problem.

If I remove all the databindings from all controls except cboStudents, I can
circle through the students fine using the Next button and the drop-down box
itself.

This form is designed similar to another form in my application, and the
other form works just fine.

I would really appreciate some help with this one.
 
Nathan said:
I have a form with combo boxes, text boxes, and radio buttons bound
to a dataset table (Students) taken from an Access database. The

I refer to the subject only: If you don't get an answer here, you may turn
to microsoft.public.dotnet.framework.windowsforms.databinding
 
Back
Top