Winforms ListView - Stop automatically checking when double clicking

后端 未结 5 1477
粉色の甜心
粉色の甜心 2021-02-19 04:15

How do I make a listview not automatically check an item when I double click it?

I can try hooking into the MouseDoubleClick event, and set the Checked property to false

5条回答
  •  无人及你
    2021-02-19 04:30

    I use a much simpler method of just resetting the checkbox's value to the original state by changing it to the opposite of what it currently is:

        Private Sub lst_Images_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lst_Images.DoubleClick
            Dim fIndex As Integer = Me.lst_Images.SelectedIndices(0)
            ' Undo the changing of the checkbox's state by the double click event. 
            lst_Images.Items(fIndex).Checked = Not lst_Images.Items(fIndex).Checked
    
            ' Call the viewer form
            Dim fViewer As New Image_Edit(fIndex)
            fViewer.ShowDialog()
            fViewer.Dispose()
    End Sub
    

提交回复
热议问题