how to refresh button in C# windows application?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Manish Kumar ChoudharyPosted Mar 10, 2015, 5:38 AM
What you have, should refresh the current form that that event belongs to. It is hard to make out what your problem is due to the lack of intelligable information (what is happening and why are you saying it does not work? etc.). However, you could try
private void Refresh_Click(object sender, EventArgs e)
{
this.Update();
}
The difference between the two methods is thus:
Control.Update()
The Update() function calls the UpdateWindow function which updates the client area of the control by sending WM_PAINT message to the window (of the control) if the window's update region is not empty. This function sends a WM_PAINT directly to WNDPROC() bypassing the application message queue.
Thus, if the window update region is previously "invalidated" then calling "update" would immediately "update" (and cause repaint) the invalidation.
Control.Refresh()
Refresh() calls Invalidate(true) to invalidate the control and its children and then calls Update() to force paint the control so that the invalidation is synchronous.
I hope this helps.
Ranjit PowarPosted Mar 10, 2015, 5:37 AM