|
-
March 17th, 2003, 06:40 PM
#1
Help with a variable error message...
I'm getting the following error message, and can't figure out why:
C:\CPP\MyTestApp\MyTestApp\FormMain.cs(118): Cannot modify the return value of 'System.Windows.Forms.Control.Location' because it is not a variable
Here is the line of code it refers to:
this.Location.X = Convert.ToInt32(ReadXMLConfigFile ("WindowLocationX"));
Any idea why "this.Location.X" is not a variable, when it takes an INT?
Thanks! 
- Adrian
-
March 17th, 2003, 07:11 PM
#2
System.Windows.Form.Location has to be assigned a Point type, and the X and Y property of that point type in Location cannot be modified directly. so just creat a Point and assign it the values from config file then
Point p = new Point(x,y);
this.Location = p;
-
March 17th, 2003, 07:15 PM
#3
the reason is X and Y of location is a property. it needs the Point object.
for example
this.Location = new Point(100,100);
-Paresh
- Software Architect
-
March 17th, 2003, 09:49 PM
#4
You could also use the Left and/or Top property, instead of location.
That which does not kill us, only makes us stronger.
MCSD .NET
-
March 18th, 2003, 12:30 PM
#5
in fact both are same in the sense that when you assign X,Y of Location
and Left & Top of control. both are property. in location you can set at a time and give a point. where as Left and Top would be considered as a 2 diff. statements
Paresh
- Software Architect
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|