Changing a form's location

  • Thread starter Thread starter Tharpa Roberts
  • Start date Start date
T

Tharpa Roberts

I'm trying to make a button that will change the location of the form. I
would have thought that the following code would do the trick:

this.Location.X = this.Location.X + 1;



however, this gives me the error:



this.Location.X = this.Location.X + 1;

Any suggestions?
 
Tharpa Roberts said:
I'm trying to make a button that will change the location of the form. I
would have thought that the following code would do the trick:

this.Location.X = this.Location.X + 1;

The Location property returns a Point - which is a value type.
Basically, if the compiler let you do this, it wouldn't do what you
wanted anyway.

Instead, to use just Location, you'd need:

Location = new Point(Location.X+1, Location.Y);

There may be a better way, although I can't see one immediately.
 
Jon said:
The Location property returns a Point - which is a value type.
Basically, if the compiler let you do this, it wouldn't do what you
wanted anyway.

Instead, to use just Location, you'd need:

Location = new Point(Location.X+1, Location.Y);

There may be a better way, although I can't see one immediately.

Looks pretty good to me. Thanks, Jon.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top