I have 3 list views: PokedexList, PkmFormList, and PkmAbList. PokedexList is populated from a database when the form loads. When the user selects a pokemon from PokedexList it populates PkmFormList with all the forms of the selected pokemon. When a form is selected from PkmFormList, PkmAbList is populated with the abilities of the selected pokemon form. This is what's expected and this is what it does. However, it only does it for the first item selected.
Example: I select "Absol" from PokedexList, that populates PkmFormList with Absol's two forms, "Normal" and "Mega." However, if I then decide that, instead of "Absol", I wanted "Deoxys", I would expect PkmFormList to be populated with "Normal", "Attack", "Defense", and "Speed". Instead, it pops an error that says "InvalidArgument=Value of '0' is not valid for 'index'."
Private Sub PokedexList_SelectedIndexChanged(sender As Object, e As EventArgs) Handles PokedexList.SelectedIndexChanged
'shows the selected pokemon as part of your party
If Pkm1Select.Checked = True Then
For Each item As ListViewItem In PokedexList.SelectedItems
Pkm1Txt.Text = item.Text
Next
ElseIf Pkm2Select.Checked = True Then
For Each item As ListViewItem In PokedexList.SelectedItems
Pkm2Txt.Text = item.Text
Next
ElseIf Pkm3Select.Checked = True Then
For Each item As ListViewItem In PokedexList.SelectedItems
Pkm3Txt.Text = item.Text
Next
ElseIf Pkm4Select.Checked = True Then
For Each item As ListViewItem In PokedexList.SelectedItems
Pkm4Txt.Text = item.Text
Next
ElseIf Pkm5Select.Checked = True Then
For Each item As ListViewItem In PokedexList.SelectedItems
Pkm5Txt.Text = item.Text
Next
ElseIf Pkm6Select.Checked = True Then
For Each item As ListViewItem In PokedexList.SelectedItems
Pkm6Txt.Text = item.Text
Next
End If
'pulls a list of forms for the selected pokemon
Dim SqlQry As String = "SELECT [Pokemon_forms].[pokemon_id], [Pokemon].[id], [Pokemon].[identifier], [Pokemon_forms].[form_identifier] " &
"FROM [Pokemon], [Pokemon_forms] WHERE (([Pokemon].[id]=[Pokemon_forms].[pokemon_id])) AND [Pokemon].[identifier] = ?;"
DbCommand = New OleDbCommand(SqlQry, DbConnection)
Dim IdentifierParam As New OleDbParameter("?", OleDbType.VarChar)
DbCommand.Parameters.Add(IdentifierParam)
IdentifierParam.Value = PokedexList.SelectedItems(0).Text
DbConnection.Open()
Dim da As OleDbDataAdapter = New OleDbDataAdapter(DbCommand)
Dim ds As DataSet = New DataSet
da.Fill(ds, "Pokemon_forms")
Dim dt As DataTable = ds.Tables("Pokemon_forms")
Dim row As DataRow
For Each row In dt.Rows
Dim FormIdentifier As String = row("form_identifier")
FormIdentifier = StrConv(FormIdentifier, vbProperCase)
PkmFormList.Items.Add(FormIdentifier)
Next
DbConnection.Close()
End Sub
Any ideas how to fix this?