By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,837 Members | 1,195 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,837 IT Pros & Developers. It's quick & easy.

Move a control at runtime?

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a

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.