Another Newbie Listbox Question

  • Thread starter Thread starter Glen
  • Start date Start date
G

Glen

I am using two listboxes on a windows form. The objects listed in the
first listbox (A) can be dragged and dropped into the second listbox
(B).

This works great and was quite easy. Of course, as part of that
process, I intercept the mousedown event for listbox-A to begin the
drag/drop operation.

However, I ALSO want to be able to detect the double-click selection of
an item in listbox-A so that I can pop up a new form with details about
that item.

The problem seems to be that the mousedown event "short circuits" the
double click event for that listbox (A).

(Code Below)

What am I doing wrong? Any suggestions would be greatly appreciated.

Sincerely,
Glen Wolinsky


--------------------------
Numbers 6:24-26
--------------------------


#Region "Associates Mouse_Down"
Private Sub lbxAssociates_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles lbxAssociates.MouseDown
If e.Button = MouseButtons.Left Then _

lbxAssociates.DoDragDrop(lbxAssociates.SelectedValue.ToString,
DragDropEffects.Copy)

End Sub

#End Region

#Region "Assignments Drag Enter"
Private Sub lbxAssignments_DragEnter(ByVal sender As Object,
ByVal e As System.Windows.Forms.DragEventArgs) Handles
lbxAssignments.DragEnter
If (e.Data.GetDataPresent(DataFormats.Text)) Then
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If

End Sub

#End Region

#Region "Assignments Drop"
Private Sub lbxAssignments_DragDrop(ByVal sender As Object,
ByVal e As System.Windows.Forms.DragEventArgs) Handles
lbxAssignments.DragDrop

'Do some processing

end sub
#End Region
 
IMO you shouldn't start the drag-drop operation until you're
actually dragging something (i.e. moving you mouse).
So set a flag in MouseDown to indicate which item to drag
(and reset it in MouseUp). Then in MouseMove check
the flag and start your drag-drop operation if it is set

Then the doubleclick events should work aswell

/claes
 
Back
Top