G
Guest
Ok, this is the first time I've tried a serious use of Drag and Drop.
As a test, I first defined 2 instances of a very basic user control on a
form. The user control had one string type public property. All the dragdrop
event handlers needed were defined automatically by VS from the individual
instances (MouseDown, MouseMove, DragEnter, DragDrop). (This was all based
on that article http://msdn2.microsoft.com/en-us/library/aa289508(VS.71).aspx
- Implementing Drag and Drop in VisualBasic.Net)
This test worked fine. (I also went back and assigned a panel as the 2
usercontrols parent. It still works.)
Now in the real application, what I want to do is dynamically define a
number of usercontrols based on the data and attach them to a panel. In
other words, define a loop and for each record:
Dim x as new UserControl1
-- define it's properties
-- Attach the event handlers
AddHandler x.MouseDown, AddressOf ControlMouseDown
AddHandler x.DragDrop, AddressOf ControlDragDrop
AddHandler x.MouseMove, AddressOf ControlMouseMove
AddHandler x.DragEnter, AddressOf ControlDragEnter
Now the event handlers aren't firing, not even MouseDown. I've set the
AllowDrop property of each control instance to True. What else could I be
forgetting?
As a test, I first defined 2 instances of a very basic user control on a
form. The user control had one string type public property. All the dragdrop
event handlers needed were defined automatically by VS from the individual
instances (MouseDown, MouseMove, DragEnter, DragDrop). (This was all based
on that article http://msdn2.microsoft.com/en-us/library/aa289508(VS.71).aspx
- Implementing Drag and Drop in VisualBasic.Net)
This test worked fine. (I also went back and assigned a panel as the 2
usercontrols parent. It still works.)
Now in the real application, what I want to do is dynamically define a
number of usercontrols based on the data and attach them to a panel. In
other words, define a loop and for each record:
Dim x as new UserControl1
-- define it's properties
-- Attach the event handlers
AddHandler x.MouseDown, AddressOf ControlMouseDown
AddHandler x.DragDrop, AddressOf ControlDragDrop
AddHandler x.MouseMove, AddressOf ControlMouseMove
AddHandler x.DragEnter, AddressOf ControlDragEnter
Now the event handlers aren't firing, not even MouseDown. I've set the
AllowDrop property of each control instance to True. What else could I be
forgetting?