System.Windows.Forms.Control.ControlCollection.SetChildIndex C# (CSharp) Method

SetChildIndex() public method

public SetChildIndex ( Control child, int newIndex ) : void
child Control
newIndex int
return void
			public virtual void SetChildIndex (Control child, int newIndex)
			{
				if (child == null)
					throw new ArgumentNullException ("child");
				
				int old_index;
				
				old_index = list.IndexOf (child);
				if (old_index == -1)
				{
					throw new ArgumentException ("Not a child control", "child");
				}
				
				if (old_index == newIndex)
				{
					return;
				}
				
				all_controls = null;
				list.RemoveAt (old_index);
				
				if (newIndex > list.Count)
				{
					list.Add (child);
				}

				else
				{
					list.Insert (newIndex, child);
				}
				//child.UpdateZOrder();
				owner.PerformLayout ();
			}