Hi Lam,
depends on what kind of control you are trying to update. You can use a
System.Window.Forms.Timer to cause an event to fire every few seconds which
calls a method, inside the method you can fetch your new values and update
your control i.e.
//event that handles a start button being clicked - you don't need this but
I just put it hear for clarity in the example.
System.Windows,Forms.Timer m_objTimer = null;
public void btnStart(Object sender, EventArgs e)
{
//if it is already running need to stop existing timer
if(m_objTimer != null)
{
m_objTimer.Stop();
}
else
{
m_objTimer = new System.Windows.Forms.Timer();
}
//set the number of milliseconds between each timer event ie 10sec
m_objTimer.Interval = 10000;
//add the handler function that will handle to timer tick event
m_objTimer.Tick += new EventHandler(m_objTimer_Tick);
}
public void btnStop(Object sender, EventArgs e)
{
//if it is already running need to stop existing timer
if(m_objTimer != null)
{
m_objTimer.Stop();
}
}
//this function is called every time the timer raises a tick event
private void m_objTimer_Tick(object sender, EventArgs e)
{
//fetch data from database
//update controls with new data
this.labelCurrentValue.Text = strDatabaseText
}
Hope that helps
Mark.