Listbox SelectedItem & Dragging

G

Guest

I have a Windows app (.net v1.1) and I am dragging from a list box.

The first drag works fine, but all subsequent drags continue to pull the
first item that was dragged. It appears that MouseDown does not cause the
SelectedItem to change (even though the highlighted item changes).

So, if I click down on a non-highlighted item and drag it off the list box,
the new item looks selected, but is not really the SelectedItem. I see that
the SelectedItem is only changed on MouseUp, which never happens because I
dragged off of the list box.

Is there something I can put in mouse down to select the new item? This
would make SelectedItem act like the highlighting does, which would make more
sense and fix the issue with dragging.

Thank you for your assistance,
Mark Lauser
 
C

Cor Ligthert

Mark,

Ask this to the guy who made the program

He can see maybe something in the code from by instance the mouse down event
you are talking about.

We don't have nothing to see that here.

I hope this helps,

Cor
 
G

Guest

Cor,

I am the guy who made the program.

There is no code to look at in the mouse down event. I was hoping that
someone familiar with dragging and dropping from list boxes could help me
figure out what code to put in there so that the list box item is selected as
soon as the mouse down event occurs.

Thank you,
Mark Lauser
 
G

Guest

Use the IndexFromPoint function of the ListBox and use the X and Y of the
MouseEventArgs (e) to specify the point:

Dim index As Integer = ListBox.IndexFromPoint(New Point(e.X, e.Y))
If index >= 0 Then ListBox.SelectedIndex = index

Have a nice day,
Mark Lauser
 

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