private void OpenChangeValueDialog(object sender, EventArgs e)
        {
            if (!(sender is ToolStripItem menuItem))
            {
                return;
            }
            if (!(menuItem.Owner is ContextMenuStrip owner))
            {
                return;
            }
            Label senderLabel = (Label)owner.SourceControl;

            if (senderLabel == null)
            {
                return;
            }

            TableLayoutPanelCellPosition position = uiElement.GetPositionFromControl(senderLabel);
            int c = position.Column;
            int r = position.Row;

            if (r > rows.Count)
            {
                return;
            }

            List <Control> valueControls       = new List <Control>();
            List <Control> nonValueControls    = new List <Control>();
            int            valueControlsHeight = 5;
            int            tabIndexCounter     = 0;

            TableValue value = rows[r - 1].values[c];

            value.BuildValueControls(columns[c].name, 5, 300, ref valueControls, ref nonValueControls, ref valueControlsHeight, ref tabIndexCounter);

            Form prompt = new Form
            {
                StartPosition = FormStartPosition.CenterParent,
                Width         = 325,
                Height        = valueControlsHeight + 70,
                Text          = "Change value"
            };

            bool confirmed = false;

            foreach (Control valueControl in valueControls)
            {
                valueControl.KeyDown += (sender2, e2) => { if (e2.KeyCode == Keys.Return)
                                                           {
                                                               confirmed = true; prompt.Close();
                                                           }
                };
                prompt.Controls.Add(valueControl);
            }
            foreach (Control nonValueControl in nonValueControls)
            {
                prompt.Controls.Add(nonValueControl);
            }

            Button confirmation = new Button()
            {
                Text = "Add", Left = 205, Width = 100, Top = valueControlsHeight
            };

            confirmation.TabIndex = tabIndexCounter;
            confirmation.Click   += (sender2, e2) => { confirmed = true; prompt.Close(); };
            prompt.Controls.Add(confirmation);
            prompt.ShowDialog();

            if (confirmed)
            {
                value.SetValueWithControls(valueControls);
                OnTableChanged();
            }
        }
        void OpenAddRowDialog(object sender, EventArgs e)
        {
            List <List <Control> > valueControls    = new List <List <Control> >();
            List <Control>         nonValueControls = new List <Control>();
            int valueControlsHeight = 5;
            int tabIndexCounter     = 0;

            foreach (TableColumn column in columns)
            {
                List <Control> columnControls = new List <Control>();
                column.defaultValue.BuildValueControls(column.name, 5, 300, ref columnControls, ref nonValueControls, ref valueControlsHeight, ref tabIndexCounter);
                valueControls.Add(columnControls);
                valueControlsHeight += 10;
            }

            Form prompt = new Form
            {
                StartPosition = FormStartPosition.CenterParent,
                Width         = 325,
                Height        = valueControlsHeight + 70,
                Text          = "Add " + rowName
            };

            foreach (List <Control> columnControls in valueControls)
            {
                foreach (Control valueControl in columnControls)
                {
                    prompt.Controls.Add(valueControl);
                }
            }
            foreach (Control nonValueControl in nonValueControls)
            {
                prompt.Controls.Add(nonValueControl);
            }

            bool confirmed = false;

            Button confirmation = new Button()
            {
                Text = "Add", Left = 205, Width = 100, Top = valueControlsHeight
            };

            confirmation.TabIndex = tabIndexCounter;
            confirmation.Click   += (sender2, e2) => { confirmed = true; prompt.Close(); };
            prompt.Controls.Add(confirmation);
            prompt.ShowDialog();

            if (confirmed)
            {
                TableRow newRow = new TableRow();
                for (int i = 0; i < columns.Count; ++i)
                {
                    TableValue newValue = Program.DeepClone(columns[i].defaultValue);
                    newValue.SetValueWithControls(valueControls[i]);
                    newRow.values.Add(newValue);
                }
                rows.Add(newRow);

                OnTableChanged();
            }
        }