public TableDesignForm(DatabaseContext dbContext, Database database, Table table = null) { InitializeComponent(); this.dbContext = dbContext; this.database = database; DialogResult = DialogResult.Cancel; TableDataGridView.CellValueChanged += new DataGridViewCellEventHandler(CreateTableDataGridView_CellValueChanged); TableDataGridView.DataError += CreateTableDataGridView_DataError; if (table != null) { TableNameTextBox.Text = table.Name; TableNameTextBox.Enabled = false; TableDataGridView.Rows.Add(table.Columns.Count); int index = 0; foreach (var column in table.Columns) { TableDataGridView.Rows[index].Cells[0].Value = column.Name; TableDataGridView.Rows[index].Cells[1].Value = DataTypeConverter.ToComboType(column.Type); TableDataGridView.Rows[index].Cells[2].Value = column.Size; if (table.PrimaryKey.Contains(column.Name)) { TableDataGridView.Rows[index].Cells[3].Value = true; } else { TableDataGridView.Rows[index].Cells[3].Value = false; } if (column.Unique) { TableDataGridView.Rows[index].Cells[4].Value = true; } else { TableDataGridView.Rows[index].Cells[4].Value = false; } if (column.Nullable) { TableDataGridView.Rows[index].Cells[5].Value = true; } else { TableDataGridView.Rows[index].Cells[5].Value = false; } index++; } } else { relationshipsButton.Enabled = false; } }