"Selected Items", drag and drop and owner draw ListBox.

R

Robin Tucker

Trouble up mill -

My owner draw list box allows me to multiple-select. Once the items have
been selected, clicking one of them in order to drag and drop all those
selected, selects the item I click on the "mouse down" event (oddly enough),
so only the first item shows as being selected for the drag and drop
operation! Oddly (more so), the "mouse up" event seems to change the
selected item in the list box. End result? Impasse.

(just in case that wasn't too clear [its always so much easier if you are
allowed to post pictures]).... consider you have selected 4 items. They are
now drawn as "selected" (ie. blue backgrounds). Now you want to drag/drop
these items into another window. So you press the left mouse button on one
of the selected items. Stupidly, the control de-selects all items except
the item you have just press the mouse button down on.

(here is how I'm drawing an item):


Private Sub ListBox_DrawItem(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.DrawItemEventArgs) Handles ListBox.DrawItem

' Guard
If e.Index < 0 Then
Exit Sub
End If

Dim theItem As DataThumbnailViewItem = CType(ListBox.Items()(e.Index),
DataThumbnailViewItem)

If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
theItem.Render(e.Graphics, e.Bounds, True)
Else
theItem.Render(e.Graphics, e.Bounds, False)
End If

End Sub
 
J

John Smith

I believe that the drag operation was not fully developed for vb.net
2002/2003

When trying to drag the selected text from a textbox the seleccion
vanishes too.

My solution: subclass the control and correct the behaviour
Of course this will take lot's of effort and time.
May be next VB will be completely developed...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top