My Form defines a ContextMenuStrip:
Dim CMS As New ContextMenuStrip
Button1.ContextMenuStrip = CMS
There is also a Listview with 5 columns and some data:
ListView1.View = View.Details
How can I display the content of SubItems at index 1
and K of the first 5
Items of this ListView in a ContextMenuStrip?
CMS.Items.Clear()
For i As Integer = 0 To 5
Dim line As String = ListView1.Items(i).SubItems(1).Text
Dim line1 As String = ListView1.Items(i).SubItems(3).Text
CMS.Items.Add(line & "|" & line1)
Next i
If the ListView contains are less than 5
ListViewItems, I get an exception.
If there is one ListViewItem in the ListView, then create one MenuItem.
If there are more than 5 ListViewItems, then display only values from the first 5 Items.