dataform wizard.

alanchinese

Regular
Joined
Jan 12, 2005
Messages
62
i made a simple dataset containing only one datatable using the xml schema designer of vs.net.
then i made a form using the dataform wizard, binding the data to individual controls.
whenever adding or deleting the records, i display the count of the bindingcontext, and the rows of the table, i noticed the numbers are not matching...

when i add 3 records, it display 3 bindingcontext counts, but only 2 rows of data in the table. where did i make the mistake?

here are portions of my code:
// Flight.xsd
element: Flight (Flight)
element: Name string
element: Type string
// FlightForm.vb
...
'editName
Me.editName.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.objFlight, "Flight.Name"))
...
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Try
'Clear out the current edits
Me.BindingContext(objFlight, "Flight").EndCurrentEdit()
Me.BindingContext(objFlight, "Flight").AddNew()
Catch eEndEdit As System.Exception
System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
End Try
End Sub
...
Private Sub btnInfo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInfo.Click
Dim sb As New System.Text.StringBuilder
sb.Append("bindingcontext: " + Me.BindingContext(objFlight, "Flight").Count.ToString + Environment.NewLine)
sb.Append("datatable name: " + Me.objFlight.Tables(0).TableName + Environment.NewLine)
sb.Append("datarow count: " + Me.objFlight.Tables(0).Rows.Count.ToString + Environment.NewLine)
MessageBox.Show(sb.ToString)
End Sub
 
Back
Top