Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > VB.NET-BindingSource/DataGridView
 

VB.NET-BindingSource/DataGridView

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.

CruzPedro  Friday, January 05, 2007 12:18 AM

Hi,

Maybe you can do in this way?

Adapter;

privatevoid 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]);

}

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

DamPee  Wednesday, January 10, 2007 11:36 AM

Hi,

Maybe you can do in this way?

Adapter;

privatevoid 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]);

}

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

DamPee  Wednesday, January 10, 2007 11:36 AM

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

CruzPedro  Wednesday, January 10, 2007 5:14 PM
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 automaticallygenerate Delete and Update Functions for my Adapter. The solution forme 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 magicallyrefresh 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!
toulipa  Monday, March 12, 2007 1:15 PM

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.

Ismael Recinos1  Wednesday, March 28, 2007 7:11 PM

You can use google to search for other answers

Custom Search

More Threads

• datagridview combobox databinding problem
• checkbox problem
• DataBinding Issues using IEditableObject
• Problem: DataBind() in DataGrid
• Binding to array list
• DataGridView not deleting correct rows
• DataGridView and KeyValuePairs
• Validating a bound combobox, type error.
• Problem: Active EditingControl in DataGridView + ResetBindings call
• Dataset insert in mysql database????