CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2000
    Posts
    48

    Smile 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

  2. #2
    Join Date
    Feb 2003
    Location
    Oklahoma City, OK
    Posts
    63
    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;

  3. #3
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    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

  4. #4
    Join Date
    Nov 2002
    Location
    Tatooine
    Posts
    155
    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

  5. #5
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    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
  •  





Click Here to Expand Forum to Full Width

Featured