Ejemplo n.º 1
0
        /// <summary>
        /// Removes the specified number of columns from the right side of the table.
        /// </summary>
        /// <param name="count">The number of columns to remove from the right side of the table.</param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="count"/> is less than 0 -or-
        /// when <paramref name="count"/> is greater than the number of columns currently in the table.</exception>
        public void RemoveColumns(int count)
        {
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException("count", "Value cannot be less than 0.");
            }

            if (count > ColumnCount)
            {
                throw new ArgumentOutOfRangeException("count", "Value cannot be greater than the number of columns currently in the table.");
            }

            var list = ColumnHeaders.ToList();

            for (int i = list.Count - 1; i >= list.Count - count; i--)
            {
                NativeCell.RemoveChild(list[i]);
                list.RemoveAt(i);

                var cc = columnControls[i];
                foreach (var control in cc)
                {
                    NativeCell.RemoveChild(control);
                }
            }

            Array.Resize(ref columnControls, ColumnCount - count);
            ColumnHeaders = new ReadOnlyCollection <Label>(list);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds the specified number of columns to the right side of the table.
        /// </summary>
        /// <param name="count">The number of columns to add to the right side of the table.</param>
        /// <param name="headerTexts">Optional strings to apply to the header labels of the new columns.</param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="count"/> is less than 0.</exception>
        public void AddColumns(int count, params string[] headerTexts)
        {
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException("count", "Value cannot be less than 0.");
            }

            var list         = ColumnHeaders.ToList();
            int currentCount = ColumnCount;

            Array.Resize(ref columnControls, currentCount + count);

            for (int i = 0; i < count; i++)
            {
                var label = new Label();
                label.Text = headerTexts != null && headerTexts.Length > i ? headerTexts[i] : null;
                label.HorizontalAlignment = HorizontalAlignment.Left;
                label.VerticalAlignment   = VerticalAlignment.Center;

                NativeCell.AddChild(label);
                list.Add(label);
                columnControls[currentCount + i] = new IControl[RowCount];
            }

            ColumnHeaders = new ReadOnlyCollection <Label>(list);
        }