private void refreshGameList() { if (client.RetrieveActiveGames().Length != 0) { JoinGameButton.Enabled = true; int currentSelected = listBox1.SelectedIndex; listBox1.DataSource = client.RetrieveActiveGames(); listBox1.DisplayMember = "Name"; listBox1.ValueMember = "Name"; try { listBox1.SelectedIndex = currentSelected; } catch (ArgumentOutOfRangeException) { listBox1.SelectedIndex = 0; } } else { listBox1.DataSource = new List <string> { "No Active Games Found" }; JoinGameButton.Enabled = false; } }
public JoinGame(ConquestionServiceClient ConquestionServiceClient) { InitializeComponent(); client = ConquestionServiceClient; if (client.RetrieveActiveGames().Length != 0) { listBox1.DataSource = client.RetrieveActiveGames(); listBox1.DisplayMember = "Name"; listBox1.ValueMember = "Name"; } else { JoinGameButton.Enabled = false; listBox1.DataSource = new List <string> { "No Active Games Found" }; } }