On Sat, 23 Jun 2007 22:58:29 -0700, sravan_reddy001
<sr*************@gmail.comwrote:
Can i hav the systax for that. I mean from where to call the
Invalidate() and what are the arguments to it and it will do..
I called the
-------- this.refresh() from the timer1_click event.(i had to
include a timer control to do this).
That would work too, but IMHO it is better to use Invalidate(). Calling
Refresh() forces the update to happen immediately, while calling
Invalidate() allows it to be queued and coalesced along with the normal
redrawing. It is (very slightly in most cases) more efficient to use
Invalidate(). So it is preferable for you to get into the habit of using
that instead of Refresh().
That said, I have to admit, since you say you are already using Refresh()
and since that should do basically what you want (the ultimate effect of
both Invalidate() and Refresh() is to cause the form to be invalidated,
and then a Paint event to be raised for the form), I don't really
understand what the purpose of your original question was in the first
place. Maybe I'm not answering the right question.
Is there any other metod.
please explain how to use the Invalidate() method.
You would use Invalidate() just the same way you use Refresh():
this.Invalidate();
Note that technically you don't need the "this." part of the statement
(with Invalidate() or with Refresh()). That's already implied by the
context of the code.
As for other arguments, that just depends on what you want to do. Let's
say your clock is just part of the whole form. Then instead of calling
Invalidate(), you might use the version that takes a Rectangle, where the
Rectangle is set to the portion of the form containing the clock itself.
There are other versions of Invalidate(), such as the one that takes a
Region instance. The general idea is that calling Invalidate() without
any parameters will force the entire Control (your form in this case) to
be redrawn, while passing parameters narrows the area being redrawn to
whatever you specify (which usually will make drawing faster and, if
you're not using double-buffering, less noticeable).
Pete