I am doing project in vb.net using ms access
I used listview to display data from table
I want to display different context menu strip for different column
I have done it using hard logic to get column number is as follows:
Private Function getClickedColumn(ByVal pListView As ListView, ByVal pMouseX As Integer) As Integer
Dim result As Integer = 0
'Get column rights
Dim colRights As New List(Of Integer)
Dim colWidths As New List(Of Integer)
For Each col As ColumnHeader In pListView.Columns
colWidths.Add(col.Width)
Dim colRight As Integer = 0 ' - pListView.Columns.Item(0).Width 'Subtract this if you were collecting lefts instead of rights
For i As Integer = 0 To colWidths.Count - 1
colRight += colWidths(i)
Next
colRights.Add(colRight)
Next
'Which column does the mouse X fall inside?
Dim colIndex As Integer = 0
For Each colRight As Integer In colRights
If pMouseX <= colRight Then
result = colIndex
Exit For
End If
colIndex += 1
Next
Return result
End Function
Also i want to edit any cell of the listview & update its result to database .
How can i do this?
Why not using the DataGrid instead, which will allow editing, value checks, knowing the column, …