How can I do this more efficiently? Ideally so I can call showTag without any arguments and it returns the correct comboBox.
I added the argument table to define whether the value returned by showTag was from comboBox1 or comboBox2. So if i want the value for comboBox1 I call showTag(1), if I want the value for comboBox2 I call showTag(2)
//Return the currently selected language
public string showTag(int table)
{
string LanguageSelection = String.Empty;
if (table == 1)
{
LanguageSelection = comboBox1.SelectedItem.ToString();
}
else
{
LanguageSelection = comboBox2.SelectedItem.ToString();
}
string[] LanguageTag = LanguageSelection.Split(' ');
string tag = LanguageTag[1].Replace("<", "").Replace(">", "");
return tag;
}
you have to add a SelectedIndexChanged event on the same function for your 2 combobox (go to properties of your two combobox and click event and SelectedIndexChanged)