Reputation: 171
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.
Upvotes: 2
Views: 11626
Reputation: 718
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
Upvotes: 3