Lloyd
Wed Oct 19 18:38:34 CDT 2005
Hi Tim,
Paying attention to when a Control is added or removed is easy:
OnControlAdded & OnControlRemoved is here just for that.
But even after reading SetChildIndex documentation I still don't know how my
container could automatically pick up when a developer/user call
SetChilIndex/BringToFront/SendToBack on child control (s)he added to my view
:-(
"Tim Scott" <timscott@gmail.com> wrote in message
news:1129753806.134703.57260@f14g2000cwb.googlegroups.com...
> Lloyd,
>
> The Z-Order is controlled by the order of the controls in the parent
> control's Control collection.
>
> You can set something to be top-most in the Z-order by making it first
> in the controls collection. For example:
>
> // C#
> // "this" is a class derived from Form.
> this.SuspendLayout();
> this.Controls.SetChildIndex(myScrollBar, 0);
> this.ResumeLayout();
>
> See the Controls property (a ControlCollection of Control objects).
>
>>From MSDN:
> "When SetChildIndex is called, the Control referred to by the child
> parameter is moved to the position specified by newIndex and the other
> Control references in the Control.ControlCollection are reordered to
> accommodate the move. The control with an index value of zero is at the
> top of the z-order, and higher numbers are closer to the bottom"
> From
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWindowsFormsControlControlCollectionClassSetChildIndexTopic.asp
>
> You'll still have to figure out when new controls are added to the
> parent control, and then use the code to reorder the child controls.
>
> Good luck!
>
> -- Tim S.
>