Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

multi select in listview

[Image: cq4H6vr.gif]

as you can see above, by default you can't press an item and select the next item. this code should fix the issue.

Code
Private mouseDownLV1 As Boolean
Private Sub LV1_MouseDown(sender As Object, e As MouseEventArgs) Handles LV1.MouseDown
   mouseDownLV1 = True
End Sub

Private Sub LV1_MouseMove(sender As Object, e As MouseEventArgs) Handles LV1.MouseMove
   If mouseDownLV1 Then
       Try
           LV1.Items(LV1.HitTest(e.Location).Item.Index).Selected = True
       Catch : End Try
   End If
End Sub

Private Sub LV1_MouseUp(sender As Object, e As MouseEventArgs) Handles LV1.MouseUp
   mouseDownLV1 = False
End Sub



Edit:

Better version

Code
Private Sub LV1_MouseMove(sender As Object, e As MouseEventArgs) Handles LV1.MouseMove
            Dim hitInfo = LV1.HitTest(e.Location)
            If e.Button = MouseButtons.Left AndAlso (hitInfo.Item IsNot Nothing OrElse hitInfo.SubItem IsNot Nothing) Then listView1.Items(hitInfo.Item.Index).Selected = True
    End Sub
Or you can click to the first item, hold shift, then click to the last item you want to be selected.
Nice tricks, anyway.
[Image: signaturetwo.png]
(Nov 23, 2018 11:08 PM)Vyxn Wrote:  Or you can click to the first item, hold shift, then click to the last item you want to be selected.
Nice tricks, anyway.

True, but the idea is to press and select without a keyboard.
Thank for sharing the code snipet! Like it!
What about set Listview.MultiSelect = true;
(Nov 24, 2018 05:23 AM)NYANxCAT Wrote:  True, but the idea is to press and select without a keyboard.
^^
(Nov 24, 2018 03:09 PM)cristlol Wrote:  What about set Listview.MultiSelect = true;

^^

[warn]
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
(Nov 24, 2018 03:09 PM)cristlol Wrote:  What about set Listview.MultiSelect = true;

Listview.MultiSelect It will only work if you select without selecting an item first. As you see in the image above, I'm selecting an item then move to the next item.
(Nov 24, 2018 05:23 AM)NYANxCAT Wrote:  True, but the idea is to press and select without a keyboard.

I liked your idea man.
Pretty interesting and cool example.
I'm glad you're moving away from try-catch statements and checking for null, this is a big deal. Also thanks for sharing with the community.
[Image: Syr3DlV.png]
Nice share... Thanks buddy...
BTC - bc1q3efew3yzfwhdz290dafykaw0a2w56g2j69g2c6
ETH - 0xf1c873217032468990D3313da6509D1b813c4671
USDT - 0xf1c873217032468990D3313da6509D1b813c4671
PP - [email protected]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by Mr.MagnificentFeb 26, 2019 09:40 AM 7 337 Feb 26, 2019 09:40 AM
Last Post: itcorp
[.NET] by Mad HatterJan 10, 2015 01:04 PM 12 316 Jan 10, 2015 01:04 PM
Last Post: Odus
[.NET] by SeNmaNDec 21, 2014 10:51 AM 1 110 Dec 21, 2014 10:51 AM
Last Post: Only3