Reputation: 5
how to input numbers in to the second text box. whenever I click the button it keeps appearing in the 1st textbox
My Code:
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void tbox1_TextChanged(object sender, EventArgs e)
{
}
private void one_Click(object sender, EventArgs e)
{
tbox1.Text = tbox1.Text + "1 a";
tbox2.Text = tbox2.Text + "A";
}
private void two_Click(object sender, EventArgs e)
{
tbox1.Text = tbox1.Text + "2 b";
tbox2.Text = tbox2.Text + "B";
}
private void tbox2_TextChanged(object sender, EventArgs e)
{
}
private void three_Click(object sender, EventArgs e)
{
tbox1.Text = tbox1.Text + "3 c";
tbox2.Text = tbox2.Text + "C";
}
private void four_Click(object sender, EventArgs e)
{
tbox1.Text = tbox1.Text + "4 d";
tbox2.Text = tbox2.Text + "D";
}
private void five_Click(object sender, EventArgs e)
{
tbox1.Text = tbox1.Text + "5 e";
tbox2.Text = tbox2.Text + "E";
}
private void six_Click(object sender, EventArgs e)
{
tbox1.Text = tbox1.Text + "6 f";
tbox2.Text = tbox2.Text + "F";
}
private void seven_Click(object sender, EventArgs e)
{
tbox1.Text = tbox1.Text + "7 g";
tbox2.Text = tbox2.Text + "G";
}
private void eight_Click(object sender, EventArgs e)
{
tbox1.Text = tbox1.Text + "8 h";
tbox2.Text = tbox2.Text + "H";
}
private void nine_Click(object sender, EventArgs e)
{
tbox1.Text = tbox1.Text + "9 i";
tbox2.Text = tbox2.Text + "I";
}
private void zero_Click(object sender, EventArgs e)
{
tbox1.Text = tbox1.Text + "0 j";
tbox2.Text = tbox2.Text + "J";
}
}
}
Upvotes: 0
Views: 57
Reputation: 243
Looking at your code I assume you have multiple buttons for each number and each button has its own Click event handler. So it looks like you are changing both text boxes in each event handler
private void eight_Click(object sender, EventArgs e)
{
tbox1.Text = tbox1.Text + "8 h"; // changing text box 1
tbox2.Text = tbox2.Text + "H"; // changing text box 2
}
All you need to do is to change each Click event handler to change only text box 2.
Upvotes: 1