Esempio n. 1
0
            /// <summary>
            /// Adds a <see cref="Control"/> to the end of the <see cref="ControlCollection"/>.
            /// </summary>
            /// <param name="label">The text beside the child <see cref="Control"/>.</param>
            /// <param name="child">The <see cref="Control"/> to be added to the end of the <see cref="ControlCollection"/>.</param>
            /// <param name="stretches">Whether or not <paramref name="child"/> stretches the area of the parent <see cref="Control"/></param>
            public void Add(string label, Control child, bool stretches = false)
            {
                if (string.IsNullOrEmpty(label))
                {
                    throw new ArgumentNullException(nameof(label));
                }
                if (child == null)
                {
                    throw new ArgumentNullException(nameof(child));
                }
                if (child.IsInvalid)
                {
                    throw new InvalidHandleException();
                }
                if (Owner.IsInvalid)
                {
                    throw new InvalidHandleException();
                }
                if (Contains(child))
                {
                    throw new InvalidOperationException("Cannot add the same control more than once.");
                }
                if (child.TopLevel)
                {
                    throw new ArgumentException("Cannot add a top-level control to a ControlCollectionBase.");
                }

                Libui.FormAppend(Owner.Handle, label, child.Handle, stretches);
                base.Add(child);
            }