Untitled
unknown
plain_text
a year ago
959 B
1
Indexable
Never
using System; using System.Windows.Forms; using System.Collections.Generic; public class LobbyForm : Form { private List<Button> playerButtons; private string selectedPlayer; public LobbyForm(List<string> playerNames) { this.Text = "Select Opponent"; this.Size = new Size(200, 200); playerButtons = new List<Button>(); for (int i = 0; i < playerNames.Count; i++) { var button = new Button() { Text = playerNames[i], Location = new Point(50, 30 + i * 40), Size = new Size(100, 30) }; button.Click += PlayerButton_Click; playerButtons.Add(button); Controls.Add(button); } } public string GetSelectedPlayer() { return selectedPlayer; } private void PlayerButton_Click(object sender, EventArgs e) { selectedPlayer = (sender as Button).Text; this.Close(); } }