C # designated controls appear at the top
Yesterday, a friend asked me, how kind dealing with overlapping controls, the controls for specified at the top. Me very crazy, I wonder why there is such a demand, but yesterday busy work, no time. This morning to the try to write some code, as follows:
SetMeTop located on the function button1_Click is a testing method, tested, this is feasible.
Why use a ArrryList rather than the direct use of index to be deleted, because the top of a delete controls, the controls will lead to the following have been added to an index, will produce some anomalies.
This is only a function of time on walls. Perhaps. Net itself directly there is a way to set up, I do not know. Huh ..
Welcome advice: AppleDotnet@hotmail.com
Void SetMeTop (object obj)
(
/ / Principle: the first component will be added at the top, can see the order is determined by the index.
This.Controls.GetChildIndex int index = ((Control) obj); / / to gain control of the Top index
ArrayList AL = new ArrayList ();// controls used to load containers
For (int i = 0; i <index; i ++)// the top to control the above controls are put into containers
AL.Add (this.Controls [i]);
For (int i = 0; i <AL.Count; i + +)
(
/ / Delete once and added an operation, it controls into the above to below.
This.Controls.Remove ((Control) AL [i]);
This.Controls.Add ((Control) AL [i]);
)
)
Private void button1_Click (object sender, System.EventArgs e)
(
SetMeTop (sender);
)








0 Comments to “C # designated controls appear at the top”
No Comments. Send your comment.
Leave a Reply
You must be logged in to post a comment.