Please help me

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I would like to ask 3 questions. I want to display a usercontrol in a form so I create an instance of the control with new(), and then set the location with the Location property and then use add(). No problems so far. Now I would like this picture moving from left to right so I put set the location-property, add(), and sleep(1000) inside a for-loop and increment the coordinates every time, but when I start the program the form doesn't show until the usercontrol has moved to it's end destination. Why is it like that?

I also tried first putting the usercontrol at one location and then change the location property to another coordinate(without a loop), but in this case the usercontrol is only shown at the first location instead of the second, in this experiment I would like the control to show in the second location instead of the first. What have I done wrong in this case

My third question is how do I remove a control that I have shown on a form

Thank you in advance.
 
lagoon75 said:
Hi,
I would like to ask 3 questions. I want to display a usercontrol in a form
so I create an instance of the control with new(), and then set the location
with the Location property and then use add(). No problems so far. Now I
would like this picture moving from left to right so I put set the
location-property, add(), and sleep(1000) inside a for-loop and increment
the coordinates every time, but when I start the program the form doesn't
show until the usercontrol has moved to it's end destination. Why is it like
that?

The form's thread is so busy performing the looping operation it doesn't
have time to refresh the screen. 2 possible answers.
1. Use a second thread
2. in the loop do an Application.DoEvents (this tells the thread to perform
any pending operations before continuing with the loop). Also, be sure to
invalidate the area of the form that needs to be redrawn so the thread knows
what to re-draw.
I also tried first putting the usercontrol at one location and then change
the location property to another coordinate(without a loop), but in this
case the usercontrol is only shown at the first location instead of the
second, in this experiment I would like the control to show in the second
location instead of the first. What have I done wrong in this case?
I would have to see a snippet to give you an answer on this one.
My third question is how do I remove a control that I have shown on a form?
this.Controls.Remove(MyControlInstance);
or, if you just want it to not show,
MyControlInstance.Hide();
 
Back
Top