Restricting Drag Drop Functionality

Joined
Feb 12, 2006
Messages
18
Location
Australia
Programming Experience
10+
I have successfully implemented Drag Drop from a VB.NET Treeview Control onto a textbox but need to stop the user from dragging the wrong value into the right textbox, i.e. I have 3 treeview controls and corresponding textboxes but I don't want the user to drag from treeview1 to textbox2 or textbox3 etc. Does anyone know how to determine the source control of the drag drop operation so it can be tested before allowing the value to be dropped?
 
Problem Solved

The simple task of writing down the problem made it easier to resolve. I now simply test for the name of the trreview being used, i.e.

Dim x As TreeNode
If (e.Data.GetDataPresent("System.Windows.Forms.TreeNode")) Then
x = e.Data.GetData("System.Windows.Forms.TreeNode")
If x.TreeView.Name = "tvwContacts" Then
txtPassengerName.Text = NormaliseContactName(x.Text.ToString) etc. . . .
 
the other option would be a global variable set to the source when starting the drag operation, so you could check with this on drop
 
Back
Top