What I was trying to do was way more complicated than necessary. I've got it fixed and working as expected now.
I have a number of items in the listbox (assigned to the same datasource as the datagridview). Some of the items are saved to a listof string in My.Settings, because they're currently being used and the other's are not. I am randomly selecting one that is currently in use.
Code:Public Sub SelectName() '***PICK NAME*** If My.Settings.CurrentPlayers.Count > 0 Then pick = rand.Next(0, My.Settings.CurrentPlayers.Count) Dim Itm As DataRowView = FrmSettings.PlayerList.Items(pick) Dim listedPlayer As String = DirectCast(Itm, DataRowView).Row.Item("Name").ToString If My.Settings.CurrentPlayers.Contains(listedPlayer) Then FrmSettings.TableDataGridView.Rows(pick).Selected = True 'This not really necessary D_Name = FrmSettings.TableDataGridView.Rows(pick).Cells(1).Value.ToString D_Age = GetAge(FrmSettings.TableDataGridView.Rows(pick).Cells(2).Value) D_Gender = FrmSettings.TableDataGridView.Rows(pick).Cells(3).Value Else SelectName() End If End If End Sub




Reply With Quote
