473,387 Members | 1,596 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.

Move a control at runtime?

Greetings,

I was lucky one time to have someone provide me a little code that would
allow the user to move a control at runtime. However, I lost that code
snippet when my hard drive failed and now after rebuilding most of the
program from scratch I am in need of that code again. I think it had to do
with getting the x,y of the screen location but I am dazed and confused. I
am a novice programer trying to make a program work for my model railroad
layout and need this to create a dispatcher panel.

Thanks in advance for any assistance.

Mark Gaeth
Decatur, IN
Nov 21 '05 #1
4 30621
Hi,

If you want to move a control in runtime, you can use the left and right
properties of this control.

For example, for the button control:

Button1.Left = Button1.Left + 60
Button1.Top = Button1.Top + 60

Best regards,

Jorge Serrano PĂ©rez
MVP VB.NET

"Mark Gaeth" wrote:
Greetings,

I was lucky one time to have someone provide me a little code that would
allow the user to move a control at runtime. However, I lost that code
snippet when my hard drive failed and now after rebuilding most of the
program from scratch I am in need of that code again. I think it had to do
with getting the x,y of the screen location but I am dazed and confused. I
am a novice programer trying to make a program work for my model railroad
layout and need this to create a dispatcher panel.

Thanks in advance for any assistance.

Mark Gaeth
Decatur, IN

Nov 21 '05 #2
Hi,

http://www.onteorasoftware.com/downl...ovecontrol.zip

Ken
-----------------

"Mark Gaeth" <mg****@mchsi.com> wrote in message
news:uNkQd.440$zH6.51@attbi_s53...
Greetings,

I was lucky one time to have someone provide me a little code that would
allow the user to move a control at runtime. However, I lost that code
snippet when my hard drive failed and now after rebuilding most of the
program from scratch I am in need of that code again. I think it had to do
with getting the x,y of the screen location but I am dazed and confused. I
am a novice programer trying to make a program work for my model railroad
layout and need this to create a dispatcher panel.

Thanks in advance for any assistance.

Mark Gaeth
Decatur, IN

Nov 21 '05 #3
Maybe this code can help you:

Private dragging As Boolean
Private beginX, beginY As Integer

Private Sub Button2_MouseDown(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles Button2.MouseDown

dragging = True
beginX = e.X
beginY = e.Y

End Sub

Private Sub Button2_MouseMove(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles Button2.MouseMove
If dragging = True Then
Button2.Location = New Point(Button2.Location.X + e.X -
beginX,Button2.Location.Y + e.Y - beginY)
Me.Refresh()
End If
End Sub

Private Sub Button2_MouseUp(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles Button2.MouseUp

dragging = False

End Sub

Greetz Peter
"Ken Tucker [MVP]" <vb***@bellsouth.net> schreef in bericht
news:Oe*************@TK2MSFTNGP15.phx.gbl...
Hi,

http://www.onteorasoftware.com/downl...ovecontrol.zip

Ken
-----------------

"Mark Gaeth" <mg****@mchsi.com> wrote in message
news:uNkQd.440$zH6.51@attbi_s53...
Greetings,

I was lucky one time to have someone provide me a little code that would
allow the user to move a control at runtime. However, I lost that code
snippet when my hard drive failed and now after rebuilding most of the
program from scratch I am in need of that code again. I think it had to do
with getting the x,y of the screen location but I am dazed and confused. I
am a novice programer trying to make a program work for my model railroad
layout and need this to create a dispatcher panel.

Thanks in advance for any assistance.

Mark Gaeth
Decatur, IN

Nov 21 '05 #4

Thanks everyone for your kind response and code snippets. They worked
for what I was doing. Now I just need to play with it and see what I
need to do next. I know I will need to create "as needed" new contols of
the same type so they can be moved around in a text box with the
operators assigned train number and name.

Thanks again for the link as I sure I will find new stuff and ideas for
the novice newbie.

Mark Gaeth
Decatur, IN
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #5

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

Similar topics

3
by: Shailaja Kulkarni | last post by:
hi All, This problem is for C# windows application. I have a user control whcih contains one picture box along with other controls. Depending on certain conditions I want to change images on the...
3
by: | last post by:
Hi,all I want to change Control's size&location in runtime ,(C#) but i dont know how to do! :(so, can you provide me with document about this. my email: zhonghua@rinpak.com.cn ...
8
by: Robson Machado | last post by:
Dear friens, Does anybody knows how to move controls (images, textboxes, buttons, etc..) using CodeBehind? Regards,
0
by: Avinash Patil | last post by:
I have one web user Control "AddressType.ascx". This is used mainly to add new records.The control have two buttons named cmdSave and cmdCancel and a TextBox named txtAddressType. The code for...
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...
2
by: Glenn T. Kitchen | last post by:
Hello Group, How do you position a web control you create at runtime? I thought: ===================================== Dim Label1 as Label = New Label Me.Controls.Add(Label1)...
2
by: john | last post by:
Maybe I haven't had that "a-ha" moment yet, but I think the new approach to web projects is a step in the wrong direction. My main beef is that control over the assembly generation process has...
1
by: CarterABarnes | last post by:
Hello fellow vb.net developers, Here is my issue. I am creating an application that very much needs a control like the Properties control in Visual Studio. I would like to add items to it that...
7
by: Jon Davis | last post by:
In order to gracefully handle exceptions at runtime but cause the debugger to break in the place where the exceptions occur when debugging, I used to write code like this: #if !DEBUG try {...
0
by: anupsonawane | last post by:
hi friends i want to add chechbox control in datagrid at runtime in vb.net 2005 so plz send me useful inf abt how to add this control at runtime & how to get check event on this checkbox....
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.