If I understood correctly you want tu use this method to init/reinit all your combo box controls that do not have yet index selected. For doing that you should change your method like this (because
SelectedIndex
with value
-1
means no index selected):
private void cmbIndex()
{
foreach (Control myControl in this.Controls)
{
ComboBox comboBox = myControl as ComboBox;
if (comboBox != null && comboBox.Items.Count > 0 && comboBox.SelectedIndex < 0)
{
comboBox.SelectedIndex = 0;
}
}
}