Click here to Skip to main content
15,393,377 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi there
i have 2 labels and a picturebox
the 2 labels have the picturebox as parent
i want to move label1 to label2 location
i use the following code

private void Form1_Load(object sender, EventArgs e)
            label2.Text = "stop here         ";
            make_item_transparent(label1, pictureBox1);
            make_item_transparent(label2, pictureBox1);
        private void marquee_label(Label l)
            if (l.Left > label2.Location.Y)
                l.Left = 0;
                l.Left = l.Left + 1;

        private void make_item_transparent(Label label, PictureBox bar)
            var pos = this.PointToScreen(label.Location);
            pos = bar.PointToClient(pos);
            label.Parent = bar;
            label.Location = pos;
            label.BackColor = Color.Transparent;

        private void timer1_Tick(object sender, EventArgs e)

i am sure its right
but i may miss something
label1 doesn't move to the exact location of label2

help me plz

thanx alot

[edit]Code block fixed - OriginalGriff[/edit]
Updated 31-Oct-13 7:30am
OriginalGriff 31-Oct-13 15:01pm
What does it do that you didn't expect?
What did you expect it to do that it doesn't do?
eng.iris 31-Oct-13 15:07pm
the label1 must stop moving and return to 0 location when it reached the label2 location

but it returns to zero before reaching label2 location

it doesnt do what i really want

pleeeease help , i spend alot of time in it

thanks again

1 solution

The logic of marquee_label is messed up.

You're comparing label1.Left (basically the X-coordinate) to label2.Location.Y (basically the Y-coordinate or label2.Top). Therefore, if that Left position is greater than label2.Top it gets slammed back to 0.

I believe you want to do that comparison against label2.Left if you want them to overlap, or label2.Left - label1.Width if you want them to be up against each other.
eng.iris 31-Oct-13 15:44pm
yes, u r right tgrt
now it works :)
i am so grateful to u

thanks again
tgrt 31-Oct-13 15:46pm
You're welcome.
BillWoodruff 1-Nov-13 1:47am
tgrt 1-Nov-13 12:45pm
Thanks Bill.

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