I'm developing a software and I have a little trouble. I have two combobox, the first one fills the second one but if the first combobox has a value which is equal than -1, then the second combobox is not enable. This is a peace of my code:
private void FillComboGroup()
{
try
{
//here I initialize an object
if (Convert.ToInt32(this.cboSede.SelectedValue) > -1)
{
//the code here just retrieves an object
}
else
{
this.cboEmpleado.Enabled = false;
this.cboEmpleado.BackColor = Color.White;
}
}
catch (Exception ex)
{
//here are some methods to save the exception in the log
}
Well, the first time works without problems. When the form load for first time, the second combobox is not enabled, then I change the first combobox value and the second combo is enabled now. But if I put again the first combobox in the first value("Please select an option...", which its value is -1) then the second combo is enabled. I tried with the SelectedIndexChanged and SelectionChangeCommited but doesnt work. Any idea about how to solve it? Thanks in advance.
private void cboSede_SelectedIndexChanged(object sender, EventArgs e)
{
this.FillComboGroup();
}