473,385 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Recall the PaintEvent method

in the following code i am handling the Paint event;
this event is associated with the Form1_Paint() method;

I want to recall this method. i.e the Contents of the form should be
updated every 5 seconds.(Designing the Analog Clock. How to Update
the Time)

this.Paint += new PaintEventHandler(Form1_Paint);

-- Sravan Reddy

Jun 24 '07 #1
3 3761
On Sat, 23 Jun 2007 21:14:47 -0700, sravan_reddy001
<sr*************@gmail.comwrote:
in the following code i am handling the Paint event;
this event is associated with the Form1_Paint() method;

I want to recall this method. i.e the Contents of the form should be
updated every 5 seconds.(Designing the Analog Clock. How to Update
the Time)
Basically, you have to call Invalidate() on the form instance.

More generally, the usual mechanism is that you have some data with which
you will draw the output in the Paint event. Whenever that data changes,
you call Invalidate(), optionally passing information such as a rectangle
or region indicating just what areas of the form were affected by the
change in the data.

In your case, I suppose that you are not actually storing any data, and
instead are just using the DateTime.Now property, so it would make sense
to just call Invalidate() each time your timer is signaled for a repaint.
Again, optionally restricting the invalidated area to just the part of the
form that actually has changed since the last time you handled the Paint
event.

Pete
Jun 24 '07 #2
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). Is there any other metod.
please explain how to use the Invalidate() method.

Jun 24 '07 #3
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
Jun 24 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Carlos Marangon | last post by:
Hello! I need some help. How can I recall the last 5 rows from a MySQL table and show them? Where is the FAQs of this newsgroup? Sincerely,
1
by: BjoernJackschina | last post by:
Hello, is there a possibility to recall a page in which I had entered a password before with a hint that it was the wrong password. Many thanks
2
by: Prabhu Ram Prasath | last post by:
I have a series of 5 or 6 pages each containing some 10 or 12 text box controls. I need to recall the input given in first page at the last page. How should I use the viewstate collection to...
3
by: jrhoads23 | last post by:
I have been wondering this for some time. If I create my own class inherited from an existing class or create a user control, should I be overriding the OnFontChanged method (or similar) or...
3
by: Velhari | last post by:
Hi all, Please tell me how to recall the PhP Program to execute the process after it is submitted the contents into another PhP Program....... I have used Javascript to acheive this but...
3
AsSeenonTV
by: AsSeenonTV | last post by:
Hey there! I will admit I am new to these Message Boards and to Visual Basic 6, but I am an experienced programmer when it comes to Visual Basic for Excel. Now with working with Excel, I am able...
0
by: Maninder Karir | last post by:
Hi, I have defined some lists in excel (using ctrl + F3). How can i recall these lists to a combobox? Thanks
1
by: artev | last post by:
in short to can insert in a page one file js that recall onother js page Insertion Indirect if have site/test.php site/file1.js site/a/b/file2.js and want file2.js inner file1.js and it...
1
by: Maciej Gawinecki | last post by:
Two questions related to the topic 1. If I have an empty set of relevant results, then it would be better to have no answers from the system at all. But neither precision nor recall gives...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.