473,545 Members | 2,051 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dragging a control

Does anyone have, or can anyone suggest a URL for code to drag a control
around a form at run time? VB.Net 2003.

I have written stuff in VB6 to do this before, but a long time ago and I
don't have the code to refer to anymore.

Cheers,
Tull.
Jun 22 '06 #1
2 1416
This is sample code for dragging a button at runtime, should be easy to
modify for other controls

Hope this helps
<<<<<<code>>>>> >
Private dragging As Boolean
Private beginX, beginY As Integer
Private Sub Button2_MouseDo wn(ByVal sender As Object, ByVal e As _
System.Windows. Forms.MouseEven tArgs) Handles Button2.MouseDo wn
dragging = True
beginX = e.X
beginY = e.Y
End Sub
Private Sub Button2_MouseMo ve(ByVal sender As Object, ByVal e As _
System.Windows. Forms.MouseEven tArgs) Handles Button2.MouseMo ve
If dragging = True Then
Button2.Locatio n = New Point(Button2.L ocation.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.MouseEven tArgs) Handles Button2.MouseUp
dragging = False
End Sub


--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"Tull Clancey" <tu**********@b topenworld.com> schreef in bericht
news:KM******** ************@bt .com...
Does anyone have, or can anyone suggest a URL for code to drag a control
around a form at run time? VB.Net 2003.

I have written stuff in VB6 to do this before, but a long time ago and I
don't have the code to refer to anymore.

Cheers,
Tull.

Jun 22 '06 #2
Hi Tull,

http://www.vb-tips.com/default.aspx?...1-47ef665ea0c2

I hope this helps,

Cor

"Tull Clancey" <tu**********@b topenworld.com> schreef in bericht
news:KM******** ************@bt .com...
Does anyone have, or can anyone suggest a URL for code to drag a control
around a form at run time? VB.Net 2003.

I have written stuff in VB6 to do this before, but a long time ago and I
don't have the code to refer to anymore.

Cheers,
Tull.

Jun 22 '06 #3

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

Similar topics

0
1310
by: Fred Heida | last post by:
Hi, I try to implement dragging (and dropping) of text inside a rtf control (similar as word i guess) I have set AllowdDrop = true and setup the handlers for DragDrop, DragOver, DragEnter. is there anything else i need to do ? becuase if i now select some text in the control and start dragging this, the very first time i see the 'no...
2
1186
by: Jonathan | last post by:
I have a form that has controls on it that can be dragged to other locations within the form. The form size is larger than the viewable area so the scroll bars are visible (and autoscroll is enabled). When I drag a control to the edge of the visible border, I am sending the WM_HSCROLL/WM_VSCROLL message to the parent form to initiate a...
0
1851
by: alcurb | last post by:
I have a ListView control populated with 30 items. ListView height only allows you to see 20 rows at a time. I want to drag an item to the bottom of the list (to the last row), but ListView control doesn't automatically scroll as my mouse leaves the bottom edge of the control. Also if I'm dragging an item from the last row to the top row,...
1
1789
by: ohadasor | last post by:
Hello, I have a control which I need to act in a specific way when the user drags the mouse on it. Means, that the user should click on the control's one position, hold the mouse button, move it to another position on the control, and releases the mouse. It isn't like drag and drop, when two objects are interacting. Here I have only one...
3
2375
by: Beorne | last post by:
Hello, I have to ralize a graph with a pair of straight vertical lines that have to be dragged in the left-right direction with the mouse. I've never done something similar so I wonder if someone could tell me the key C# classes to use. Thank you very much.
4
1506
by: spectecjr | last post by:
Hey folks; I've got a weird problem... whenever I try to drag and drop a toolbox item onto a form in the Window Forms editor, the control is automatically added on the first click. This gives me very little control over where it ends up, and as you can imagine, is somewhat inconvenient. Anyone know a fix for this? My work system...
0
958
by: kimiraikkonen | last post by:
Hi, I noticed that if i view some jpeg files via Picturebox control (.net 2.0) placed in to a single form, while dragging the form around the screen, then the form slutters, dragging slows down and jitters occur. With same jpeg files other 3rd party picture viewers works very well when compared to a .net 2.0 picturebox control. (original...
4
2298
by: kimiraikkonen | last post by:
Hi, On my system which is 2.4GHZ P4 CPU, 1GB memory + 64MB DDR graphic card, if i create a simple picturebox docked on a form sized about 500x350 or less or more, doesn't matter, and also if i place a normal sized picture on the control, while dragging the form having with picturebox + image, it costs about %90-%100 CPU while dragging form...
0
7475
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7409
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7918
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7436
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7766
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1897
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
715
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.