Click here to Skip to main content
15,889,808 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to move a picturebox but i want the other picturebox to appear or to start moving only after the picturebox1 gets to a specific location. Im using a timer to make it move. I am new to this thing, please understand :(

What I have tried:

private void timer1_Tick(object sender, EventArgs e)
{
picbox2.Left -= 5;
lbl2.Left -= 5;

if (picbox2.Left == 1245)//its staring point is (1367, 110)
{
lbl1.Left -= 5;
picbox1.Left -= 5;
}
}
Posted
Updated 18-Aug-16 6:40am

1 solution

If it's starting location is (1367, 100), and you subtract 5 from it each time, then it will never reach (1245, y) at all: the x coordinate will always end in a 2 or a 7, never a 5.
What I'd suggest is :
C#
if (picbox2.Left <= 1245)
   {
   ...
   }
That way, it will start moving when it gets there, and continue moving from that point.
 
Share this answer
 
Comments
Hikari18 18-Aug-16 12:47pm    
thank you very much ^_^

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900