SetChildIndex
Controls.SetChildIndex(z, index); |
I couldn't find anything that might suggest SetChildIndex fires any events and checked that Control.OnControlAdded/Control.OnControlRemoved are not being fired.
Thanks,
Ray
Controls.SetChildIndex(z, index); |
I couldn't find anything that might suggest SetChildIndex fires any events and checked that Control.OnControlAdded/Control.OnControlRemoved are not being fired.
Thanks,
Ray
Actually, I can no longer reproduce it. I put the code back to the way it was and did not hit the assertion. Here's the code I have/had for what it's worth:
#if !BUGBUG
Debug.Assert(Controls.Count > 2);
Controls.Add(z);
Debug.Assert(z == Controls[Controls.Count-1]);
z.Controls.Add(Controls[index]);
Controls.SetChildIndex(z, index); // put it back where it was
Debug.Assert(Controls[index] == z);
#else
Debug.Assert(Controls.Count > 2);
Control control = Controls[index];
z.Controls.Add(control); // reparent the control (and removes the control)
Controls.Add(z); // add the zone back in the control's place.
Debug.Assert(Controls[Controls.Count - 1] == z);
Controls.SetChildIndex(z, index); // put it back where it was
Debug.Assert(Controls[index] == z);
#endif
The first case was failing while the second case worked. I have munged other code though so the problem was quite possibly a side effect of something else. Does SetChildIndex trigger any events?
Thanks,
Ray
it seems that when x = 1, c1 is placed at 1
when x = 2, c1 is placed at 1
when x = 3, c1 is placed at 3
is anybody else confused?