Reputation: 53
OK, so, I'm trying to make it if a read-only textbox1 equals some string, then another read-only textbox2 equals some other string, depending on what textbox1 is. For example, it textbox 1 is equal to "Hey" Textbox2 will be equal to "Hi". Here's what I have:
string responseString = "Hey";
if(TextBox1.Text == ("Hi"))
{
TextBox2.Text = responseString;
}
I'm using Visual studios C# Express 2010. I'm new to this so I'm sorry for any dumb questions. My C# class hasn't gone into too much depth with String
s and loops yet. Thanks!
I'm not getting any errors by the way, it just doesn't work.
Upvotes: 1
Views: 142
Reputation: 53
private void TextBox1_TextChanged(object sender, EventArgs e)
{
string responseString = "Hi";
if (TextBox1.Text == ("Hey"))
{
TextBox2.Text = responseString;
}
}
Above is correct. I had it under the: `
private void textBox2_TextChanged(object sender, EventArgs e)
which was not correct.`
Upvotes: 0
Reputation: 66449
Your code is currently backwards from what you've described you're trying to do:
string responseString = "Hi";
if (TextBox1.Text == "Hey")
{
TextBox2.Text = responseString;
}
Upvotes: 3