Form.Location cannot be set

Class library usage, coding and language questions.
grahama
Posts: 8
Joined: Tue Apr 24, 2007 7:47 pm

Form.Location cannot be set

Post by grahama » Fri Apr 27, 2007 7:06 pm

[Using RanorexPro 1.1.0.0 in C# with .NET 2.0]

If I have a form, the following code works:

Code: Select all

Form form = ... some form ....
int x = form.Location.X;
But if I try to set the location, i.e.:

Code: Select all

form.Location.X = 5;
The compiler gives the error: Cannot modify the return value of 'Ranorex.Control.Location' because it is not a variable.

So how do I move a form?

Thanks.

admin
Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by admin » Sat Apr 28, 2007 10:47 am

We have a set operator only for the Location, please set the new location as follows:

Code: Select all

Point location = form.Location;
location.X = 5;
form.Location = location;
or

Code: Select all

form.Location = new Point(5, form.Location.Y);
Jenö
Ranorex Team