Hi. I use a ListView to display data in tabular form.
Each ListView row corresponds to a data record.
The ListView Item of the record is the record key or code.
Each SubItem in that row represents a field from the record.
I implemented a context menu so the user can "Copy" the cell content to the
clipboard with this code:
Private Sub ListView1_Mouse Down(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles ListView1.Mouse Down
'Displays a context menu with the option to "Copy" to the clipboard.
'Activate context menu if user right-clicked.
If e.Button = MouseButtons.Ri ght Then
Dim ClickPoint As Point = New Point(e.X, e.Y)
Dim LVItem As ListViewItem = ListView1.GetIt emAt(ClickPoint .X,
ClickPoint.Y)
'Copy data only if item contains some data.
If Not LVItem Is Nothing Then
'Code to copy to ciipboard...
End If
End If
End Sub
The problem is that GetItemAt() returns Nothing if the click happened on a
SubItem, that is, any column but the leftmost.
How can I allow the users to copy the data from the other columns to the
clipboard?
Thanks in advance
Richard
Each ListView row corresponds to a data record.
The ListView Item of the record is the record key or code.
Each SubItem in that row represents a field from the record.
I implemented a context menu so the user can "Copy" the cell content to the
clipboard with this code:
Private Sub ListView1_Mouse Down(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles ListView1.Mouse Down
'Displays a context menu with the option to "Copy" to the clipboard.
'Activate context menu if user right-clicked.
If e.Button = MouseButtons.Ri ght Then
Dim ClickPoint As Point = New Point(e.X, e.Y)
Dim LVItem As ListViewItem = ListView1.GetIt emAt(ClickPoint .X,
ClickPoint.Y)
'Copy data only if item contains some data.
If Not LVItem Is Nothing Then
'Code to copy to ciipboard...
End If
End If
End Sub
The problem is that GetItemAt() returns Nothing if the click happened on a
SubItem, that is, any column but the leftmost.
How can I allow the users to copy the data from the other columns to the
clipboard?
Thanks in advance
Richard
Comment