Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I refresh c# dataGridView after update ?

I have a dataGridView when I click on any row a form is opened to update the row data, but after ending updates the updating form is closed but the dataGridView data is not updated

How can i do that ?

like image 646
amer Avatar asked Aug 10 '11 09:08

amer


People also ask

How do I refresh my computer using command prompt?

Within the Command Line window, type gpupdate /force and then press Enter on your keyboard. The line "Updating Policy..." should appear in the Command Line window below where you just typed. When the update has finished, you should be presented with a prompt to either logoff or restart your computer.

Has C been updated?

The latest update of C is called C18 and the standard was published in June 2018. It is almost identical to C11, published in 2011. Before that was C99. Although C11 has some significant changes from C99 they are all C and not that different.


1 Answers

BindingSource is the only way without going for a 3rd party ORM, it may seem long winded at first but the benefits of one update method on the BindingSource are so helpful.

If your source is say for example a list of user strings

List<string> users = GetUsers(); BindingSource source = new BindingSource(); source.DataSource = users; dataGridView1.DataSource = source; 

then when your done editing just update your data object whether that be a DataTable or List of user strings like here and ResetBindings on the BindingSource;

users = GetUsers(); //Update your data object source.ResetBindings(false); 
like image 140
Coops Avatar answered Sep 23 '22 12:09

Coops