Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,833 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have 2 combobox if CB1 is < 2 CB say Fail. This is what I have so far.
private void cb_score_SelectedIndexChanged(object sender, EventArgs e)
{
if (cb_score.SelectedItem == "2")
{
cb_pass_fail.Text = "Fail";
}
Hi Booney-3048,
First convert the value of combobox1 to int type via Int32.TryParse method and then compare with 2.
Please refer to the following code:
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
int value;
if (Int32.TryParse(comboBox1.Text, out value))
{
if (value < 2)
{
comboBox2.Text = "Fail";
}
else
{
comboBox2.Text = "";
}
}
else
{
comboBox2.Text = "";
}
}
Best Regards,
Daniel Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.