469,330 Members | 1,287 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,330 developers. It's quick & easy.

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 29947
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Shailaja Kulkarni | last post: by
8 posts views Thread by Robson Machado | last post: by
reply views Thread by Avinash Patil | last post: by
4 posts views Thread by Nancy | last post: by
2 posts views Thread by Glenn T. Kitchen | last post: by
2 posts views Thread by john | last post: by
1 post views Thread by CarterABarnes | last post: by
7 posts views Thread by Jon Davis | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Purva khokhar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.