Untitled

 avatar
unknown
plain_text
2 years ago
887 B
4
Indexable
using System;
using System.Windows.Forms;

public class PlayerNameForm : Form
{
    private Button confirmButton;
    private TextBox nameTextBox;
    private string playerName;

    public PlayerNameForm()
    {
        this.Text = "Enter Player Name";
        this.Size = new Size(200, 200);

        nameTextBox = new TextBox() { Location = new Point(50, 30), Size = new Size(100, 30) };
        confirmButton = new Button() { Text = "Confirm", Location = new Point(50, 70), Size = new Size(100, 30) };

        confirmButton.Click += ConfirmButton_Click;

        Controls.Add(confirmButton);
        Controls.Add(nameTextBox);
    }

    public string GetPlayerName()
    {
        return playerName;
    }

    private void ConfirmButton_Click(object sender, EventArgs e)
    {
        playerName = nameTextBox.Text;
        this.Close();
    }
}
Editor is loading...