Hi all,
I have a class in which I dim a new form and listview. The purpose is to list stock items and allows the user to select an entry. I have added the addhandler itemdrag and its relevant code
When running the lvw event is activated and sets-up the dataobject (the cursor changes during the drag process) but the target Txt_Part events in the second form do not fire. The property 'allowdrop' is set to true.
This code works fine where both forms are generated through the designer. Is there something special I need to set when I create the lvw object at run time. It appears to simply not 'see' the 'other' form.
Thanks.
I have a class in which I dim a new form and listview. The purpose is to list stock items and allows the user to select an entry. I have added the addhandler itemdrag and its relevant code
AddHandler lvw.ItemDrag, AddressOf lvw_ItemDrag Private Sub lvw_ItemDrag(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemDragEventArgs) Dim myItem As New ListViewItem Dim myItems(sender.SelectedItems.Count - 1) As ListViewItem Dim i As Integer = 0 ' Loop though the SelectedItems collection for the source. For Each myItem In sender.SelectedItems ' Add the ListViewItem to the array of ListViewItems. myItems(i) = myItem i = i + 1 Next ' Create a DataObject containg the array of ListViewItems. sender.DoDragDrop(New DataObject("System.Windows.Forms.ListViewItem()", myItems), DragDropEffects.Copy) End Sub
When running the lvw event is activated and sets-up the dataobject (the cursor changes during the drag process) but the target Txt_Part events in the second form do not fire. The property 'allowdrop' is set to true.
Private Sub Txt_Part_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Txt_Part.DragEnter ' Check for the custom DataFormat ListViewItem array. If e.Data.GetDataPresent("System.Windows.Forms.ListViewItem()") Then e.Effect = DragDropEffects.Copy Else e.Effect = DragDropEffects.None End If End Sub Private Sub Txt_Part_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Txt_Part.DragDrop Dim y As Integer = e.Y Dim x As Integer = e.X Dim myItem As New ListViewItem Dim myItems() As ListViewItem = e.Data.GetData("System.Windows.Forms.ListViewItem()") For Each myItem In myItems Txt_Part.Text = myItem.Text Next myItem = Nothing myItems = Nothing End Sub
This code works fine where both forms are generated through the designer. Is there something special I need to set when I create the lvw object at run time. It appears to simply not 'see' the 'other' form.
Thanks.