bindingsource.addnew()

p_nivalis

Active member
Joined
Oct 1, 2004
Messages
33
Programming Experience
5-10
I have a datagridview and a few textboxes bound to a dataset.
VB.NET:
da.Fill(dsBox, "tblStuff")
bs.DataSource = dsBox
bs.DataMember = "tblStuff"
 
dgvBox.DataSource = bs
txtTitle.DataBindings.Add("Text", bs, "Dogs")
Controls.Add(txtTitle)
I have buttons on the form to remove, add, save, etc., but I am having troubles getting it to add. Deleting and saving records to the dataset works fine, but I can't get add to work.

I am using bs.addnew() to add a new record.

The following is hard to follow, but this is what happens:
When I click on the button for bs.addnew() it is supposed to clear out the textboxes that are bound but it does not. A new record is added at the end of the datagridview, but it does not select like it like it is supposed to. When I scroll down to the new record and select it, I see in the textboxes that it contains data from the first record in the table, but in the datagridview it shows all the columns as being empty. What is going on here?
 
Last edited by a moderator:
Private bs As BindingManagerBase = Me.BindingContext(dsBox, "tblStuff")

then use bs.AddNew() in a button
 
Back
Top