Location Property of a Control ( X and Y)

I am working with a form that has  3 Panels and 1 GridView. During the running of my program I shift the panels and Grid  positions using the Top and Bottom properties.

What I am finding that the GridView will have different Location X and Y values after I run the program and view the Location X and Y properties in the design properties window.
How could that happen? I thought Location X and Y values are readonly values.
Lawrence AverySystem DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kyle AbrahamsSenior .Net DeveloperCommented:
Windows or ASP.Net?

For a windows application you can set the location.X

for a asp.net application you can adjust the style via a margin or set the positioning to absolute.
0
Lawrence AverySystem DeveloperAuthor Commented:
This is a windows application. I thought Location.X and Location.Y are not variables.

 In other words, by using say GridView.Left or GridView.Top you can change the positioning of the control during runtime but the Location X and Y always contain the same values that were established during design time.
0
Kyle AbrahamsSenior .Net DeveloperCommented:
You can use either.

If you type in gridView.Location.X in the tool tip you'll see gets or sets . . . at least that's how it is for me - running .net 4.0 in VS 2010.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Lawrence AverySystem DeveloperAuthor Commented:
Here is my code:

        private void rcp_QHdr_Info_Collapsed(object sender, EventArgs e)
        {
            // Need to position Grid Lines upward
            rgv_Quote_QLines.Left = rcp_QHdr_Info.Left;
            rgv_Quote_QLines.Top = rcp_QHdr_Info.Bottom + 60;
            rgv_Quote_QLines.Location.X = 5;

        }
When I compile or even hold my mouse pointer over the code (rgv_Quote_QLines.Location) - it indicates
Cannot modify the return value of 'System.Windows.Control.Location' because it is not a variable.
0
Lawrence AverySystem DeveloperAuthor Commented:
I am using VS 2012 .NET 4.5
0
Kyle AbrahamsSenior .Net DeveloperCommented:
   
    Point pt = rgv_Quote_QLines.Location;
   pt.X = 5;
   rgv_Quote_QLines.Location = pt;  // not sure if this line is necessary but showing you can assign the location to a valid point.

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Lawrence AverySystem DeveloperAuthor Commented:
I've requested that this question be deleted for the following reason:

I changed my code to get around issue for now. Will revisit the issue when time permits and resubmit the question.
0
Kyle AbrahamsSenior .Net DeveloperCommented:
The question was answered.  X and Y are not read only values.
0
Lawrence AverySystem DeveloperAuthor Commented:
I don't believe the answer above is  true. You cannot change Location.X or Y in  in VS2012.
When I compile or even hold my mouse pointer over the code (rgv_Quote_QLines.Location) - it indicates
 Cannot modify the return value of 'System.Windows.Control.Location' because it is not a variable.
0
Kyle AbrahamsSenior .Net DeveloperCommented:
That's because you're doing:

rgv_Quote_Qlines.Location.X

this is wrong.

You can do:
http://www.experts-exchange.com/Programming/Microsoft_Development/Q_28498703.html#a40263898
0
Lawrence AverySystem DeveloperAuthor Commented:
Oh Ok. What you are saying is that you cannot directly assign X or Y but you can assign it by using a Point class type.
Alright. Sorry I missed that.
0
Kyle AbrahamsSenior .Net DeveloperCommented:
Correct.  And no issues, thanks for working it out :-).
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.