I'm new to coding so please be gentle with me. I've tried researching the topic but can not seem to find an answer that will put me onto the right path.
I have a program that has a ListView and in the ListView each item holds a tag for a file path to an image. when I select each item I read the tag and then display the image using the image path. The problem I have is that when I right click on an item it selects the item. I would like to only allow right mouse click for a context menu strip option & have the left mouse click be the selector of item(s).
I've tried quite a few things but I am a bit puzzled on how to implement this?
Here is my code for selecting the new image.
Public Sub LoadSelectedImageFromList()
If ScanBtnPressed = False Then
If ImagesListViewBx.SelectedItems.Count > 0 Then
Dim SelectedFilePath As String = ImagesListViewBx.SelectedItems(0).Tag.ToString().Trim
Dim OpenFileName As New ImGearLocalFile(SelectedFilePath)
Using fileContent As FileStream = OpenFileName.OpenToRead()
Dim page As ImGearPage = ImGearFileFormats.LoadPage(fileContent, 0)
MainImageView.Page = page
' Reset Display settings
MainImageView.Display = New ImGearPageDisplay(MainImageView.Page)
MainImageView.Update()
End Using
ImageLoaded = True
ImagesListViewBx.SelectedItems(0).Selected = True
ImagesListViewBx.Focus()
End If
End If
End Sub
Public Sub ImagesListViewBx_ItemSelectionChanged(sender As Object, e As ListViewItemSelectionChangedEventArgs) Handles ImagesListViewBx.ItemSelectionChanged
' nScreenTracer Is to Keep Item Selected If User Clicks On Blank Part Of ListView.
' If e.IsSelected Then nScreenTracer = e.Item.Index
' Read Selected Item Tag To Get Destination Of File So We Can Then Use It To Load Image To Screen.
LoadSelectedImageFromList()
End Sub
I have tried telling the mouse up/down & click events what button is being pressed by e.buttons and a couple of other ways which i have deleted now so i cant give you that code but nothing i have tried has worked.



I have found a way to achieve what I wanted. This does however show a reselection of the current selected item in the list view but I could not find another way around it.
It also stops the items from deselecting when clicking on a blank part of the list view.
If there is a better or more cleaner way of implementing this then please let me know.