Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Windows Form: How do I record textbox to a string only after a button is pressed?

$
0
0
        private void Form1_Load(object sender, EventArgs e)
        {
            label1.Text = "Input: ";
            string Playerinput;
            button1.Text = "Enter";
            richTextBox1.ReadOnly = true;
            richTextBox2.ReadOnly = true;
            MainChar Player = new MainChar();
            richTextBox1.Text = "Hello! What is your name?";
            // Insert Code here
            Player.EXP = 0;
            Player.Level = 1;
            Player.HP = 50;
            Player.MP = 50;
            string Plevel = Player.Level.ToString();
            richTextBox2.AppendText("Level: " + Plevel + "                    ");
            string PEXP = Player.EXP.ToString();
            string PMP = Player.MP.ToString();
            string PHP = Player.HP.ToString();
            richTextBox2.AppendText("EXP: " + PEXP + "                         ");
            richTextBox2.AppendText("HP: " + PHP + "                         ");
            richTextBox2.AppendText("MP: " + PMP + "                    ");
        }
    }
}
I want to record textbox1's input to string Playerinput, but only after the user has pressed a button or the return key.

Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>