I am currently working with clicking count and textBox values. Button1 purpose is to execute an specific function depending on the value that texbox7 has. I am not getting any results when I try firing the button click event. Can someone suggest/help ?
Code
private List<string> messages = new List<string>() { "Option1", "Option2", "Option3", "Option4" };
private void button1_Click(object sender, EventArgs e)
{
if (textBox7.ToString() == "Option1")
{
int min = max;
int n = 0;
string s = "";
sw.Start();
}
else if (textBox7.ToString() == "Option2")
{
}
else if (textBox7.ToString() == "Option3")
{
}
else if (textBox7.ToString() == "Option4")
{
}
else if (textBox7.ToString() == "")
{
MessageBox.Show("Please input information");
}
}
Instead of
it should be
You should compare with the value inside the TextBox, and you can get that using Text property of the textbox.
Your
textBox7.ToString()will give you something likeSystem.Windows.Forms.TextBox, Text: text. Because of that you are not getting into any check. Compare your values against theTextproperty and it should work.