Extended multiselect in .net listview

  • Thread starter Thread starter Jonathan
  • Start date Start date
J

Jonathan

Hi all & Happy New year

What I want to do is be able to multiselect rows in a Listview just by
clicking & dragging the mouse over them (not using the shift key). So
has I move the mouse over each row it highlight & stays higlighted. I
can do it in vb6 (see code below), but not in .net

This in on the mouse_move action

If Button = vbLeftButton Then
lvtrades.SelectedItem = lvtrades.HitTest(X, Y)
End If

Cheers

All
 
Have you considered a ListView with property CheckBoxes = True?

IMHO, it is better to stick to Windows standards rather than redefining the
behavior of controls, since it can confuse users.

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
 
Carlos & all

OK, but how do I get the row to be checked as the mouse passes over it
(not using hover, it's to slow)
 
"(e-mail address removed)" <[email protected]>'s
wild thoughts were released on 5 Jan 2005 07:46:18 -0800
bearing the following fruit:
Carlos & all

OK, but how do I get the row to be checked as the mouse passes over it
(not using hover, it's to slow)

While I don't like it, you could do something like

Private flgMouseDown as boolean

Private Sub ListView1_MouseDown(ByVal sender As Object,
ByVal e As System.Windows.Forms.MouseEventArgs) Handles
ListView1.MouseDown
flgMouseDown = True
End Sub

Private Sub ListView1_MouseLeave(ByVal sender As Object,
ByVal e As System.EventArgs) Handles ListView1.MouseLeave
flgMouseDown = False
End Sub

Private Sub ListView1_MouseUp(ByVal sender As Object,
ByVal e As System.Windows.Forms.MouseEventArgs) Handles
ListView1.MouseUp
flgMouseDown = False
End Sub

Private Sub ListView1_MouseMove(ByVal sender As Object,
ByVal e As System.Windows.Forms.MouseEventArgs) Handles
ListView1.MouseMove
If flgMouseDown = True Then
If ListView1.GetItemAt(e.X, e.Y) Is Nothing Then

Else
ListView1.GetItemAt(e.X, e.Y).Selected =
True
End If
End If
End Sub


Jan Hyde (VB MVP)
 

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

Similar Threads


Back
Top