Re: Why doesn't work this asigment?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Alberto <alberto@xxxxxxxxxx> wrote:
pictureBox1.Location.X = pnl.Size.Width - 50;

pictureBox1.Location returns you a Point. Because Point is a value
type, if you made a change to X afterwards, that wouldn't change the
value of pictureBox1.Location anyway, because the value returned is
disassociated from the property.

Short answer: that's not how value types work. Use
Point p = pictureBox1.Location;
p.X = pnl.Size.Width - 50;
pictureBox1.Location = p;

(Or do it in one go as per Galcho's code.)

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.



Relevant Pages