How to refresh Datagridview content after perticular duration
I am creating a windows application,( i am very new to windows applications in .net ) in which I am displaying online users in the DataGridView control. I want to refresh the grid content after 3 seconds. plz tel me hw can i do that?
Vimal KandasamyPosted May 6, 2009, 6:46 AM
Simply add a timer control in your windows application.
then set its properties Enabled=True and Interval=3000 and in timer1_Tick() event, add your code to update data grid view content.
try this, it may help you.
Tejaswini Prashant JPosted May 7, 2009, 3:20 AM
Vimal KandasamyPosted May 7, 2009, 12:54 AM
and before call fillusers() method.simply clear the contents of datagridview.then call that function.it will add updated data.Make sure your data updated within 3 seconds.
Tejaswini Prashant JPosted May 6, 2009, 8:13 AM
Thanks for quick answer. I tried it..it's calling the timer_tick event after the given duration..but it's nt refreshing the data :(
here is my code...
private void FillUsers()
{
LinqChatDataContext _dataContext =new LinqChatDataContext();
var _users = from _u in _dataContext.LoggedInUsers
select _u;
bindingUser.DataSource= _users;
grid_users.DataSource= bindingUser;
//grid_users.Refresh();
}
private void timer_refresh_Tick(object sender, EventArgs e)
{
FillUsers();
}