C# Setting a Label (and other components) Location in run time

Posted on 2007-08-10
Medium Priority
Last Modified: 2012-05-05
C# Setting a Label (and other components) Location in run time
Label1.Location.Y = 10 or
Label1.Location.X = 5  get me an error
Error      1      Cannot modify the return value of 'System.Windows.Forms.Control.Location' because it is not a variable
Question by:amielDorel
LVL 33

Accepted Solution

hongjun earned 672 total points
ID: 19670878
You can try this

Label1.Left = 5
Label1.Top = 10

Assisted Solution

prosh0t earned 664 total points
ID: 19670909
I think you can just do this:

Label1.Location = new Point(5, 10);


Assisted Solution

by:Vasanth S
Vasanth S earned 664 total points
ID: 19670955
   You cannot set the location.x and location.y value. Since Location is property which has get/set for Point, you have to set like this.

label1.Location = new System.Drawing.Point(100, 19)

Hope this helps.


Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month15 days, 22 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question