Solved

Create a user defined controls with drag and drop

Posted on 2013-10-30
2
293 Views
Last Modified: 2013-10-30
I am writing a small control which will be an instanciated many times in a list, yet another user control.  I wish to drag and drop one or more controls from that list into another control.  Is there any reliable reference material that would help me move forward with this.  

I have done drag and drop with standard controls but this seems slightly different and any guidance or reading material would be of great help.
0
Comment
Question by:Alyanto
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 39611645
I assume you mean at run-time?

Long story, short, it's not really different than any other control.  You may need to initiate the drag from within the child controls, however.  For instance, if there is a Label in the UserControl then clicking down and dragging on it would fire events in the Label instead of the UserControl itself.  You'll have to take that into account in your code.

But basically you just do:
	Public Class UserControl1

		Private Sub UserControl1_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
			If e.Button = Windows.Forms.MouseButtons.Left Then
				Me.DoDragDrop(Me, DragDropEffects.All)
			End If
		End Sub

	End Class

Open in new window


Then handle the normal Drag/Drop events in the receiving control and move the UserControl to the new container by adding it to the Controls() collection.
0
 
LVL 1

Author Closing Comment

by:Alyanto
ID: 39611740
Nice one,
 

Many thanks

/Aly
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question