Hello,
I have a Mdi parent form that contains a List with objects as datamember. I'm trying to get the list inside a combobox on a mdi child form.
I'm using the following code:
Now I have 2 errors occuring which shouldn't be even happening:
- The method enters the beginInvoke part, although the this.InvokeRequ ired is false (checked it with debug)
- The method is executed with i = 6, while the .Count method returns 6. So according the for loop this shouldn't even be possible.
I have a Mdi parent form that contains a List with objects as datamember. I'm trying to get the list inside a combobox on a mdi child form.
I'm using the following code:
Code:
for (int i = 0; i < ((frmMain)this.MdiParent).AssignmentStatus.Count; i++ )
{
// Add the method in a save way.
if (true == this.InvokeRequired)
{
this.BeginInvoke(new MethodInvoker(delegate()
{
this.cmbstatus.Items.Add(((frmMain)this.MdiParent).AssignmentStatus[i]);
}
));
}
else
{
this.cmbstatus.Items.Add(((frmMain)this.MdiParent).AssignmentStatus[i]);
}
}
- The method enters the beginInvoke part, although the this.InvokeRequ ired is false (checked it with debug)
- The method is executed with i = 6, while the .Count method returns 6. So according the for loop this shouldn't even be possible.
Comment