moving controls at runtime
Post your questions regarding programming in C# in here.
4 posts
Page 1 of 1
ok so i have this
what im trying to do is make the label move back and forth
and i use .left because sources say one can't use .location.X
Code: Select all
but it doesnt workprivate void timer1_Tick(object sender, EventArgs e)
{
Point extended = new Point(385, 535);
Point normal = new Point(417,535);
if(label1.Location == extended)
{
label1.Left += 1;
}
if (label1.Location == normal)
{
label1.Left -= 1;
}
}
what im trying to do is make the label move back and forth
and i use .left because sources say one can't use .location.X
Instead of checking if location = point, check if location.X = 417 or location.X = 385
Why wouldn't you use label1.location.X ?
And your code is completely wrong, there is only 1 moment where it does move.
I used this way and it worked , tell me if it doesn't
And your code is completely wrong, there is only 1 moment where it does move.
I used this way and it worked , tell me if it doesn't
Code: Select all
if it doesn't work , set bool x to true Point extended = new Point(385, 535);
Point normal = new Point(417,535);
bool x = false;
private void timer1_Tick(object sender, EventArgs e)
{
if(label1.Location == extended || label1.Location == normal)
{
x = !x;
}
if(x)
{
label1.Location.X++;
}else
{
label1.Location.X--;
}
}
4 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023