Group,
I'm working with a ListView box for the first time. I've figured out how to populate it with data from a database. I now want to click one line of that ListView and have it return each of the five cells from that line into 5 textboxes. I've written the following code that is failing:
Private Sub lvPrinterSetup_Click(sender As Object, e As System.EventArgs) Handles lvPrinterSetup.Click
Dim values As New List(Of String)
If lvPrinterSetup.SelectedItems.Count > 0 Then
For Each item As ListViewItem.ListViewSubItem In lvPrinterSetup.SelectedItems(0).SubItems
values.Add(item.Text)
txbRow.Text = Convert.ToString(lvPrinterSetup.SelectedItems(0))
txbPrinterName.Text = Convert.ToString(lvPrinterSetup.SelectedItems(1))
txbPrinterName.Text = Convert.ToString(lvPrinterSetup.SelectedItems(2))
txbPrinterNo.Text = Convert.ToString(lvPrinterSetup.SelectedItems(3))
txbPrinterAddress.Text = Convert.ToString(lvPrinterSetup.SelectedItems(4))
Next
End If
End Sub
This is failing with error notes saying the .SelectedItems(1) "InvalidArgument=Value of '1' is not valid for 'index'. Parameter name: index"
I'm sure that 2 - 4 will fail as well too. Clearly I've written this incorrectly. This is where my lack of programming knowledge and experience is showing up!!
So how do I get these 5 items from one line that I've clicked into the various textboxes?
In advance, thanks for your assistance
Don