class ComboBoxCompany
{
public string Code;
public string Name;
public string Database;
public ComboBoxCompany(string code, string name, string database)
{
Code = code; Name = name; Database = database;
}
public override string ToString()
{
// Generates the text shown in the combo box
return Name;
}
}
class ComboBoxDatabase
{
public string cmpName;
public string dbName;
public ComboBoxDatabase(string cmpname, string dbname)
{
cmpName = cmpname; dbName = dbname;
}
public override string ToString()
{
// Generates the text shown in the combo box
return cmpName + " - " + dbName;
}
}
these are the classes for the 2 comboboxes, so when i select a value of the first one(ComboBoxCompany), i want that the second combobox(ComboBoxDatabase) chooses the "dbName"-Value from the first combobox "Database"-Value
i tried this, but it doesn't
private void cbxBranch_SelectedIndexChanged(object sender, EventArgs e)
{
cbxDatabase.SelectedItem = (cbxCompany.SelectedItem as ComboBoxCompany).Database;
}