Ejemplo n.º 1
0
        internal void UpdateRow(TableRow row, bool align = true)
        {
            CreateTopLeftButton();

            if (row.control == null)
            {
                var rButton = new TableRowButton(ColumnsStyle);
                rButton.Size = new Size(40, row.Height);
                rButton.Text = Rows.Count.ToString();

                row.control = rButton;
                Controls.Add(rButton);
            }

            if (row.Items.Length != Columns.Count)
            {
                row.AddjustItemsCountTo(Columns.Count);
            }

            if (row.ItemsControls == null)
            {
                row.ItemsControls = new TableRow.TableRowControlsCollection(row, Columns.Count);
            }
            if (row.ItemsControls.Length != row.Items.Length)
            {
                var newControls = new Control[Columns.Count];
                if (row.ItemsControls.Length > newControls.Length) // Dispose unnecessary controls.
                {
                    Array.Copy(row.ItemsControls.items, 0, newControls, 0, newControls.Length);
                    for (int i = newControls.Length; i < row.ItemsControls.Length; i++)
                    {
                        row.ItemsControls[i].Dispose();
                    }
                }
                else
                {
                    Array.Copy(row.ItemsControls.items, 0, newControls, 0, row.ItemsControls.Length);
                }
                row.ItemsControls.items = newControls;
            }
            for (int i = 0; i < row.Items.Length; i++)
            {
                if (row.ItemsControls[i] != null)
                {
                    continue;
                }

                int     controlColumn = i;
                TextBox itemControl   = new TextBox();
                itemControl.BorderColor  = Color.Transparent;
                itemControl.Size         = new Size(Columns[i].Width, row.Height);
                itemControl.TextChanged += (s, a) =>
                {
                    row.Items[controlColumn] = itemControl.Text;
                };
                if (row.Items[i] != null)
                {
                    itemControl.Text = row.Items[i].ToString();
                }

                row.ItemsControls[i] = itemControl;
            }

            if (align)
            {
                AlignRows();
            }
        }
Ejemplo n.º 2
0
        internal void UpdateRow(TableRow row)
        {
            CreateTopLeftButton();

            if (row.control == null)
            {
                var rButton = new TableRowButton(ColumnsStyle);
                rButton.row  = row;
                rButton.Size = new Size(40, row.Height);

                row.control = rButton;
                row.UpdateHeaderText();
                Controls.Add(rButton);
            }

            row.control.Visible = !rowHeadersHidden;

            if (row.Items.Length != Columns.Count)
            {
                row.AddjustItemsCountTo(Columns.Count);
            }


            if (row.ItemsControls == null)
            {
                row.ItemsControls = new TableRow.TableRowControlsCollection(row, Columns.Count);
            }
            if (row.ItemsControls.Length != row.Items.Length)
            {
                var newControls = new Control[Columns.Count];
                if (row.ItemsControls.Length > newControls.Length) // Dispose unnecessary controls.
                {
                    Array.Copy(row.ItemsControls.items, 0, newControls, 0, newControls.Length);
                    for (int i = newControls.Length; i < row.ItemsControls.Length; i++)
                    {
                        var rowC = row.ItemsControls[i];
                        if (rowC != null)
                        {
                            rowC.Dispose();
                        }
                    }
                }
                else
                {
                    Array.Copy(row.ItemsControls.items, 0, newControls, 0, row.ItemsControls.Length);
                }
                row.ItemsControls.items = newControls;
            }

            if (SkipControlsInitializations == false)
            {
                for (int i = 0; i < row.Items.Length; i++)
                {
                    if (row.ItemsControls[i] != null)
                    {
                        continue;
                    }

                    int     controlColumn = i;
                    TextBox itemControl   = new TextBox();
                    itemControl.BorderColor  = Color.Transparent;
                    itemControl.Size         = new Size(Columns[i].Width, row.Height);
                    itemControl.TextChanged += (s, a) =>
                    {
                        row.Items[controlColumn] = itemControl.Text;
                    };
                    if (row.Items[i] != null)
                    {
                        itemControl.Text = row.Items[i].ToString();
                    }

                    row.ItemsControls[i] = itemControl;
                }
            }
        }
Ejemplo n.º 3
0
        internal void UpdateRow(TableRow row)
        {
            CreateTopLeftButton();

            if (row.control == null)
            {
                var rButton = new TableRowButton(ColumnsStyle);
                rButton.row = row;
                rButton.Size = new Size(40, row.Height);
                rButton.Text = Rows.Count.ToString();

                row.control = rButton;
                Controls.Add(rButton);
            }

            row.control.Visible = !rowHeadersHidden;

            if (row.Items.Length != Columns.Count)
                row.AddjustItemsCountTo(Columns.Count);


            if (row.ItemsControls == null)
                row.ItemsControls = new TableRow.TableRowControlsCollection(row, Columns.Count);
            if (row.ItemsControls.Length != row.Items.Length)
            {
                var newControls = new Control[Columns.Count];
                if (row.ItemsControls.Length > newControls.Length) // Dispose unnecessary controls.
                {
                    Array.Copy(row.ItemsControls.items, 0, newControls, 0, newControls.Length);
                    for (int i = newControls.Length; i < row.ItemsControls.Length; i++)
                    {
                        var rowC = row.ItemsControls[i];
                        if (rowC != null)
                            rowC.Dispose();
                    }
                }
                else
                    Array.Copy(row.ItemsControls.items, 0, newControls, 0, row.ItemsControls.Length);
                row.ItemsControls.items = newControls;
            }

            if (SkipControlsInitializations == false)
                for (int i = 0; i < row.Items.Length; i++)
                {
                    if (row.ItemsControls[i] != null) continue;

                    int controlColumn = i;
                    TextBox itemControl = new TextBox();
                    itemControl.BorderColor = Color.Transparent;
                    itemControl.Size = new Size(Columns[i].Width, row.Height);
                    itemControl.TextChanged += (s, a) =>
                    {
                        row.Items[controlColumn] = itemControl.Text;
                    };
                    if (row.Items[i] != null)
                        itemControl.Text = row.Items[i].ToString();

                    row.ItemsControls.items[i] = itemControl;
                }
        }