C# foreach aborted

Asked

Viewed 161 times

0

When I try to move the controls of a FlowLayouPanel to another flpPropriedades -> flpReserva through a loop foreach he leaves in the middle and does not complete the transition.

foreach (Control control in flpPropriedade.Controls)   
{             
   flpReserva.Controls.Add(control);   
}

flpReserva.Refresh();
flpPropriedade.Refresh();

What could cause the unexpected output of the loop?

  • This must be happening when you do Refresh inside the foreach and your property control is in use by the loop.

  • I don’t refresh inside the foreach

  • I don’t refresh inside the foreach

1 answer

0

The solution found was to cycle do...While:

do
{
    flpReserva.Controls.Add(flpPropriedade.Controls[0]);
}
while (flpPropriedade.Controls.Count != 0);
  • Your answer was quite incomplete. Where is the rest of the question code? flpReserva use ː } to delimit the part of your code to have a more intuitive look.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.