I am trying to set the selectedindex on another form (form2) based on the user selected index on the first form (form1).
I am getting the value with this code but it returns a negative number.
public int SelectedComboIndex
{
get { return comboBox1.SelectedIndex; }
}
And I am trying to set the comboBox Index by
comboBox1.SelectedIndex = form1.SelectedComboIndex;
Can anyone point me in the right direction as to how to do this?
Edit: More code for where its calling the code on form1
Form1 form1 = null;
public Form2(Form1 parentForm1) : this()
{
form1 = parentForm1;
}
SelectedIndex
value of-1
means that nothing is selected, are you sure something is selected? The default will be-1
for thecombBox1.SelectedIndex
– SwDevMan81