CruzPedro

Hi,

I've a DGV on my form application.

The DGV.Datasource is set to Me.MyBindingSource. I this the right way

I'm using the Filter Method of the BindingSource to show only the rows I want of my DataSet.

When I delete some rows at run time in code (...rows.delete) and even after I update the Table, using the TableAdapter.Update method, not always this changes are reflected on the DGV, why is this happening

Must I do some kind of refresh to the DataSet/BindingSource maybe a new Fill to the DataSet I not sure how to solve this...

Help please.

Pedro.



Re: Windows Forms Data Controls and Databinding VB.NET-BindingSource/DataGridView

Zhi-Xin Ye - MSFT

Hi,

Maybe you can do in this way

SqlDataAdapter Adapter;

private void Button1_Click(object sender, EventArgs e)

{

DataRow dr = ds.Tables[0].NewRow();

dr[0] = 10;

dr[1] = "test";

ds.Tables[0].Rows.Add(dr);

Adapter.Update(ds.Tables[0]);

}

Hope this helps.Regards.

Ye






Re: Windows Forms Data Controls and Databinding VB.NET-BindingSource/DataGridView

Damiaan

When you need to refresh after a delete, you can do this like this:

MyBindingSource.ResetBindings(false);
This causes a control bound to the BindingSource to reread all the items in the list and refresh their displayed values.

There exist similar functions called ResetCurrentItem and ResetItem.

Kind regards





Re: Windows Forms Data Controls and Databinding VB.NET-BindingSource/DataGridView

CruzPedro

Hi,

My doubts were the need to refresh and how

Some changes on the DataSet (rows.delete) not always are viewed on the DataGridView. This is a problem...

I assume that refresh is needed, can you confirm that

Regards,

Pedro





Re: Windows Forms Data Controls and Databinding VB.NET-BindingSource/DataGridView

toulipa

Well, I don't know if this is the case, but here's what happened to me: The refreshing of the dataset was not immediate and I had trouble reloading the Identity column to the dataset on AddNew. Also, the Wizard could not automatically generate Delete and Update Functions for my Adapter. The solution for me was to change the database user in the ConnectionString: As soon as I assigned a user with db owner permissions, everything was solved, everything would magically refresh without me having to do anything. I wasn't able to find this solution over the internet, I just spent a whole day trying different things and this worked. Hope this helps!



Re: Windows Forms Data Controls and Databinding VB.NET-BindingSource/DataGridView

Ismael Recinos

I have similar situation, but this solution dont work in next case:

One form have un DataGridView for edit one table with some records, if you have more than two user working with this application (or two instance from same app running) dont refresh data modify by other user in my DGV until execute un Fill again, its necesary this Fill or exist a method more eficient

Thanks.