How to Refresh datagridview continously after Updating
almost all datagridview' s refreshing / updating the values will send you onto same way..and in this way the easiest of to "refresh" your dgv is to put this line when you need refreshing values
yourDataGridview.DataSource = yourDataRetrievingMethod // in your situation your dataset and/or table
user1447345
Updated on June 04, 2022Comments
-
user1447345 almost 2 years
I am using This code for Updating my datagrid view after the data is updated in access database.The Data is updated for every second i kept this code in a loop in a background but when i am starting the background a big X is being displayed.
try { OleDbDataAdapter dAdapter; OleDbCommandBuilder cBuilder; DataTable dTable; BindingSource bSource = new BindingSource(); dAdapter = new OleDbDataAdapter("Select * from data", cls_rt.con); //create a command builder cBuilder = new OleDbCommandBuilder(dAdapter); //create a DataTable to hold the query results dTable = new DataTable(); //fill the DataTable dAdapter.Fill(dTable); //BindingSource to sync DataTable and DataGridView bSource = new BindingSource(); //set the BindingSource DataSource bSource.DataSource = dTable; DataGridView.DataSource = dTable; } catch (Exception) { }
Then I used this code
try { this.dataTableAdapter.Fill(this.rTDataSet.data); }
and kept this in loop
dataDataGridView.Update();
then
dataDataGridView.Refresh();
then
dataDataGridView.RefreshEdit();
but it dint work for me
I want my datagridview to update for every second and one more thing when it gets update i dont want the whole gridview to update i just want the particular cell to be update.
Their would be a great appreciation if someone could help me.
Thanks In Advance.
-
SimpleVar almost 12 yearsWhy would you update it every second? You can have a Repository, in charge of accessing the BL and to cache all data, in a bindable manner, and bind the DGV to it.
-
user1447345 almost 12 yearsits a live data it updates every second that is why i want to update
-
user1447345 almost 12 yearscan you say me how can i do it @YoryeNathan because i dont have any idea about what you are saying.
-
SimpleVar almost 12 yearsYou must have something that is in charge of getting the live data and updating, right?
-
user1447345 almost 12 yearsyes you are right that is why i want it to refresh for every second..
-
SimpleVar almost 12 yearsI mean other than the DGV. You should have some updating logic someplace. Make a class that is in charge of getting the live data into a BindingList<T>
-
user1447345 almost 12 yearscan you give me some sample code or say me what i should change in my code.
-
SimpleVar almost 12 yearsFirst let me understand your situation as clear as possible. You are accessing the DB, so how is the data live? Is the DB being changed all the time? Who changed it?
-
user1447345 almost 12 yearsI am downloading a file from my server and inserting that data in a database.and then i am updating the data by its symbol like UPDATE Data SET [Date]='2011-06-08' where [Symbol]='" + gold + "'; and i want my datagridview to display it after the update of data
-
SimpleVar almost 12 yearsYou are downloading and then inserting into the DB with the same application? Please explain the whole thing thoroughly.
-
user1447345 almost 12 yearsI am Downloading the data and inserting it into a database and updating the data for every second with the same application.I Just want to read the database after the updation completes and display it Hope You Understood.
-
SimpleVar almost 12 yearsWhy won't you update the DGV when a bunch of data is downloaded? Download in bunches, as you do now, insert to DB, and update the DGV with the already-in-hand data.
-