How to add new record in a form with BindingManagerBase used?

D

Davis

Dear Experts,

I have a problem on adding new record in a form, with btnAdd_Click function,
the record stays at current record...even with a clear form function, it
only clear the record currently staying at. Seems that the datatable in ds
doesn't go to "AddNew" mode... or I need to do anything?? (btnNavNext_Click
works fine with the BindingManagerBase)

What should I do if all controls are binded with

txtOrderID.DataBindings.Add("Text", ds, "Order.OrderID")


Please help...
Thanks!!

Davis





Dim bm As BindingManagerBase
Dim ds As New DataSet
.......

Form_OnLoad:
bm = BindingContext(ds, "Order")
.......


Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
Try
blnAdd = True
bm.EndCurrentEdit()
bm.AddNew()
bm.Position = ds.Tables("Order").Rows.Count -1

ClearForm() '-- Clear control values
Catch ex As Exception
MsgBox(ex.ToString, MsgBoxStyle.Exclamation)
End Try
End Sub


Private Sub btnNavNext_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNavNext.Click
bm.Position += 1
End Sub
 
C

Cor Ligthert

Davis,

Can you try to change this?
Try
blnAdd = True
bm.EndCurrentEdit()
bm.AddNew()
bm.Position = ds.Tables("Order").Rows.Count -1

ClearForm() '-- Clear control values
Catch ex As Exception
MsgBox(ex.ToString, MsgBoxStyle.Exclamation)
End Try

In
\\\
blnAdd = True
bm.AddNew()
bm.EndCurrentEdit()
///

I hope this helps

Cor
 
C

Cor Ligthert

Davis,

Strange because I tested this one before and it did work fine for me.

Did you try it?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top