Click here to Skip to main content
15,884,849 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all

who know how to make datagridview refresh every 2mins without have data duplicate? because i want to write the small program to detect any website live streaming to know the web address isn't online or offline, that why need to make code to refresh all data which store in datagridview to refresh it.

What I have tried:

pls share me how to do this code if you have known the solution?
Posted
Updated 16-May-21 5:08am

1 solution

If you use a DataTable as the DataSource to load the DGV with data,any changes to the datasource will be reflected in the DGV automatically:
C#
private DataTable items = new DataTable();
 /// <summary>
 /// Called once when form displayed for first time
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void FrmMain_Shown(object sender, EventArgs e)
     {
     items.Columns.Add("URL");
     items.Columns.Add("Name");
     items.Rows.Add("https://www.codeproject.com/", "CodeProject");
     myDataGridView.DataSource = items;
     }
 private void AddARow_Click(object sender, EventArgs e)
     {
     items.Rows.Add("A new URL", "A new name");
     }
 
Share this answer
 
Comments
Mr.Kim2050 16-May-21 11:16am    
hi OriginalGriff

do you have sample in vb.net ?
OriginalGriff 16-May-21 11:28am    
"remove the semicolons"
"Ignore the method headers"
"ignore the curly brackets."

Alternatively, try an online converter, if you really can't work it out ...

http://converter.telerik.com/
Mr.Kim2050 16-May-21 11:18am    
an example like this, if I dont want to connect the datasource again to refresh to table of datagrideview but i want use the information which ready store in datagrideview to refresh by select any column i need, isn't possiblem ? that because inside the program i just need only one column refresh is enough to know which website is online or offline
OriginalGriff 16-May-21 11:29am    
You don't. You connect the DT once, and any changes you make to it are reflected in the DGV because the DataTable and DataGridView classes are both binding aware.
Mr.Kim2050 16-May-21 11:46am    
thanks i will try to do it, hope it really works

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900