Esempio n. 1
0
        /// <summary>
        /// Fills the instance with the given controls in the two arrays.
        /// Both arrays must have the same size. Otherwise an <see cref="ArgumentException"/>
        /// will be thrown.
        /// </summary>
        /// <param name="labels">Array with <see cref="Label"/> objects</param>
        /// <param name="controls">Array with <see cref="Control"/> objects</param>
        public void Fill(Label[] labels, Control[] controls)
        {
            if (labels.Length != controls.Length)
                throw new ArgumentException("Number of specified labels must match the number of specified controls.", "labels");

            Clear();

            _labels = new Label[labels.Length];
            labels.CopyTo(_labels, 0);
            _controls = new Control[controls.Length];
            controls.CopyTo(_controls, 0);

            for (int i = 0; i < _labels.Length; i++)
                this.Controls.Add(_labels[i]);
            for (int i = 0; i < _controls.Length; i++)
                this.Controls.Add(_controls[i]);

            RefreshLayout();
        }