473,387 Members | 1,711 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to move a control at run time

I want to move a textbox to the same position as another combobox at run
time, but got compilation error.

I use the Location.X and Location.Y but no luck.
Nov 7 '06 #1
5 30760
Hi Alan,
use the Left and Top properties instead to change the control location.
The reason you cannot say:

myControl.Location.X = 50;

is because Location returns a Point structure, this is passed by value so a
copy is made when the value is returned from the call to the property, so you
would not be assigning to the point structure located inside the control
instance but to a temporary copy that would be lost, in effect this is not an
lvalue.

Mark.
--
http://www.markdawson.org
"Alan T" wrote:
I want to move a textbox to the same position as another combobox at run
time, but got compilation error.

I use the Location.X and Location.Y but no luck.
Nov 7 '06 #2
An alternative method is to replace the Point in Location with a new
Point, for instance the Location of another control.

textBox1.Location = comboBox1.Location;
On Tue, 07 Nov 2006 08:08:01 +0100, Mark R. Dawson
<Ma*********@discussions.microsoft.comwrote:
Hi Alan,
use the Left and Top properties instead to change the control location.
The reason you cannot say:

myControl.Location.X = 50;

is because Location returns a Point structure, this is passed by value
so a
copy is made when the value is returned from the call to the property,
so you
would not be assigning to the point structure located inside the control
instance but to a temporary copy that would be lost, in effect this is
not an
lvalue.

Mark.


--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 7 '06 #3

Morten Wennevik wrote:
An alternative method is to replace the Point in Location with a new
Point, for instance the Location of another control.

textBox1.Location = comboBox1.Location;
Agreed. This is what I would do. If you have to make some modifications
to the location, say 10 pixels to the right of the combo box and 4
pixels down, use a construction like:

textBox1.Location = new Point(comboBox.Location.X + 10,
comboBox.Location.Y + 4);

or perhaps it's nicer to read:

textBox1.Location = new Point(comboBox.Left + 10, comboBox.Top + 4);

Nov 7 '06 #4
Hi Mark,

That doesn't compile, so it can't be the problem.

--
Dave Sexton

"Mark R. Dawson" <Ma*********@discussions.microsoft.comwrote in message
news:85**********************************@microsof t.com...
Hi Alan,
use the Left and Top properties instead to change the control location.
The reason you cannot say:

myControl.Location.X = 50;

is because Location returns a Point structure, this is passed by value so a
copy is made when the value is returned from the call to the property, so
you
would not be assigning to the point structure located inside the control
instance but to a temporary copy that would be lost, in effect this is not
an
lvalue.

Mark.
--
http://www.markdawson.org
"Alan T" wrote:
>I want to move a textbox to the same position as another combobox at run
time, but got compilation error.

I use the Location.X and Location.Y but no luck.

Nov 7 '06 #5
Nvm

The thread title says "run time" but the OP says "compile time"

I didn't read it thoroughly ;)

--
Dave Sexton

"Mark R. Dawson" <Ma*********@discussions.microsoft.comwrote in message
news:85**********************************@microsof t.com...
Hi Alan,
use the Left and Top properties instead to change the control location.
The reason you cannot say:

myControl.Location.X = 50;

is because Location returns a Point structure, this is passed by value so a
copy is made when the value is returned from the call to the property, so
you
would not be assigning to the point structure located inside the control
instance but to a temporary copy that would be lost, in effect this is not
an
lvalue.

Mark.
--
http://www.markdawson.org
"Alan T" wrote:
>I want to move a textbox to the same position as another combobox at run
time, but got compilation error.

I use the Location.X and Location.Y but no luck.

Nov 7 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Pedro | last post by:
Hello, I'm having a problem with the Media Player control. Sometimes, when I use the value from currentPositionString property of the Media PLayer Control I get a different value from the one...
0
by: Max | last post by:
I'm having some problems using SqlDataReader in the Microsoft.ApplicationBlocks.Data.SqlHelper class. In some cases it seems that the cursor does not move, and I'm not sure what is causing this. ...
1
by: Peter Wu | last post by:
Hello Group, I create a class that inherits from the System.Web.UI.WebControls.DataGrid class. Basically, what I want to do is to dynamically add a Table that contains some numbers for paging....
8
by: Robson Machado | last post by:
Dear friens, Does anybody knows how to move controls (images, textboxes, buttons, etc..) using CodeBehind? Regards,
4
by: Nancy | last post by:
BlankI'm new to VB.NET and OOP and have been reading and surfing the web in an attempt to learn and understand. At this point I'm spinning my wheels and wasting time. I want to be able to move a...
0
by: BrianDH | last post by:
Hi I am using the DT control (Time Only Format) and I am looking for a way to get the focus to always be set to the hour. As it is now focus always goes back to the last place the cursor had been...
0
by: BrianDH | last post by:
Hi I am using the DT control (Time Only Format) and I am looking for a way to get the focus to always be set to the hour. As it is now focus always goes back to the last place the cursor had...
0
by: terminator | last post by:
first: I find the 'r/l-value reference' terminology rather confusing and I find the following names for this new refrence type more suitable: temporary reference: Since it is generally intended...
1
by: umeshdchaudhari | last post by:
fist I filled value of drow down and GridView control. Now we find the databound of grid view control as per drow down value at time binding. ? How we find the value of control time of binding in...
1
by: Ninoy | last post by:
I am doing a program in vb 6.0 what code will i use in order to separate date and time in listview and move the time in the next column and also how can i do a loop with it so that the last date and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.