if (comboBox2.SelectedItem.ToString() == "Yes")
{
textBox1.IsEnabled = false;
textBox1.Text = "Good Health";
}
else
{
textBox1.IsEnabled = true;
}i have tried this and also used comboBox2.selectedvalue.equals("Yes") but the result is still the same.
Jignesh TrivediPosted Dec 19, 2013, 6:12 AM
agree with Satyapriya Nayak, it must work if you compare proper value in proper event..
Satyapriya NayakPosted Dec 19, 2013, 5:21 AM
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
textBox1.Text = "";
if (comboBox1.SelectedItem.ToString() == "Yes")
{
textBox1.Enabled = true;
textBox1.Text = "Good Health";
}
else
{
textBox1.Enabled = false;
}
}
private void Form1_Load(object sender, EventArgs e)
{
textBox1.Enabled = false;
comboBox1.Items.Add("Yes");
comboBox1.Items.Add("No");
}
}
}