I'm writing a program where I need to "click and drag" labels across the form. I'm planning on doing this by moving them to the position of the cursor. However, I'm having trouble finding the position relative to the top left corner of the form, and regardless of whether or not it is above other objects. Everything I'm finding on the internet is outdated, so if anyone can tell me how to do it in VB.NET 2013, thank you. Also, if there is some easier way to do drag and drop, PLEASE let me know! :P Thanks in advance.

Recommended Answers

All 5 Replies

Minimalist, the code works great, except the Handles clasuses in the sub statements all return errors, any suggestions?

Thats how I handle some of the Addhanlers:

AddHandler lab.Click, AddressOf labMouseClick
                    AddHandler lab.DragEnter, AddressOf labDragEnter
                    AddHandler lab.MouseDown, AddressOf labMouseDown
                    AddHandler lab.DragDrop, AddressOf labDragDrop
                    AddHandler lab.MouseUp, AddressOf labMouseUp
                    AddHandler lab.MouseMove, AddressOf labMouseMove
                    Me.Controls.Add(lab)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.