TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
gary.perkin
NA
1
0
Why is "Refresh" needed?(Smooth Progress Bar User Control)
Sep 29 2004 4:36 AM
Hi, As a newbie, I was interested to read this article about creating a User Control. http://support.microsoft.com/default.aspx?scid=kb;EN-US;323116 I copied the code from the webpage, compiled the user control code into a DLL, compiled the sample client application, and the progress bar worked fine. I then started to tinker with it, and I found that my code did not work in all situations. I found that although the provided sample code drew the Progress Bar OK in the timer1Tick event handler, my button2Click event handler needed to call the Refresh method of the User Control. Without the refresh, the progress bar would not move at all until the "for" loop had finished, when it simply filled the whole bar. There was no progress at all, let alone smooth progress! The code I added to the sample on the MS site is below. Anyone know why this does not work without the Refresh? I'm guessing that maybe it's do do with the fact that in the supplied code, the Value is incremented once per event, whereas in my code, the increment from 1 to 100 is all in one event, and the repaint only occurs when the event handler completes. As I say, that's only a guess though. Thanks in advance for any enlightenment. Gary. Here are the two Event Handlers. void button2Click(object sender, System.EventArgs e) { for ( int i = 0; i <= 100; i++) { this.userControl12.Value = i; // WHY DOES THIS NEED A REFRESH??? this.userControl12.Refresh(); } } void timer1Tick( object sender, EventArgs e ) { if (this.userControl11.Value <= 100) { this.userControl11.Value++; // BUT THIS DOESN'T??? } else { this.timer1.Enabled = false; } }
Reply
Answers (
1
)
how can i assign the socket permission to ntd winform
What are the differences between windows forms and Web forms