/// <summary> /// Adds a <see cref="Control"/> to the <see cref="ControlCollection"/> at the specified index. /// </summary> /// <param name="existing">The existing control at which child should be inserted.</param> /// <param name="child">The <see cref="Control"/> to insert into the <see cref="ControlCollection"/>.</param> /// <param name="relativeAlignment">The relative placement of the child control to the existing one.</param> /// <param name="width">The width of the child.</param> /// <param name="height">The height of the child.</param> /// <param name="hexpand">The horizontal expand of <paramref name="child"/>.</param> /// <param name="vexpand">The vertical expand of <paramref name="child"/>.</param> /// <param name="alignment">The alignment of <paramref name="child"/>.</param> public void Insert(Control existing, Control child, RelativeAlignment relativeAlignment, int width, int height, int hexpand, int vexpand, Alignment alignment) { if (width < 0) { throw new ArgumentOutOfRangeException(nameof(width)); } if (height < 0) { throw new ArgumentOutOfRangeException(nameof(height)); } if (existing == null) { throw new ArgumentNullException(nameof(existing)); } if (existing.IsInvalid) { throw new InvalidHandleException(); } if (child == null) { throw new ArgumentNullException(nameof(child)); } if (child.IsInvalid) { throw new InvalidHandleException(); } if (child.TopLevel) { throw new ArgumentException("Cannot add a top-level control to a ControlCollectionBase{TContainer, TCollection, T}."); } if (Contains(child)) { throw new InvalidOperationException("Cannot add the same control more than once."); } ToLibuiAligns(alignment, out Libui.Align halign, out Libui.Align valign); Libui.GridInsertAt(Owner.Handle, child.Handle, existing.Handle, relativeAlignment, width, height, hexpand, halign, vexpand, valign); base.Insert(existing.Index, child); }