Click here to Skip to main content
15,888,116 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I can create an array of text boxes but adding tb.dodragdrop does not make them drag and drop. what do I need to add when they are created?

This is a partial list of code so far which doesn't allow dropping image names from the image files:
VB
Dim TextCtrl(13) As TextBox
Dim xLoc1 As Integer = 10
Dim yLoc1 As Integer = 30
'-----Add textboxes as arrays
For count1 As Integer = 0 To 13
    Dim tb As New TextBox
    tb.Location = New Point(xLoc1, yLoc1)
    tb.Name = "TextCtrl"
    tb.DoDragDrop()
    Me.Controls.Add(tb)
    TextCtrl(count1) = tb '<-- This line adds the TextBox to the array.
    TextCtrl(count1).AllowDrop = True
    TextCtrl(count1).DoDragDrop(e, DragDropEffects.All)

    yLoc1 += 25
Next count1
Posted
Updated 13-Dec-14 21:14pm
v4
Comments
Richard MacCutchan 11-Dec-14 4:21am    
Basic?
ZurdoDev 11-Dec-14 8:55am    
Click improve question and show the code you are using.

1 solution

You need to add handlers to your TextBox to handle the critical DragAndDrop events: DragEnter and DragDrop: this shows how to add handlers: http://msdn.microsoft.com/en-us/library/ms743596(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-2[^]
The DragEnter handler needs to check if the data source is compatible, and set the Effect property appropriately, and the DragDrop handler needs to action the drop.
This may also help: http://msdn.microsoft.com/en-us/library/aa289508(v=vs.71).aspx[^]

Without the two handlers correctly implemented, nothing will happen.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900