private void columnsPage_ShowFromNext(object sender, EventArgs e) { columnsGrid.Rows.Clear(); idColumnComboBox.Items.Clear(); TableFactory tf = new TableFactory(); string tableName = m_Edit.TableName; Smo.Table t = tf.FindTableByName(tableName); if (t == null) { return; } // Get any domains already associated with the table IColumnDomain[] curDomains = m_Edit.ColumnDomains; columnsGrid.RowCount = t.Columns.Count; for (int i = 0; i < columnsGrid.RowCount; i++) { Smo.Column c = t.Columns[i]; idColumnComboBox.Items.Add(c.Name); DataGridViewRow row = columnsGrid.Rows[i]; row.Cells["dgcColumnName"].Value = c.Name; Smo.DataType dt = c.DataType; string dataType = dt.SqlDataType.ToString().ToLower(); if (dt.SqlDataType == Smo.SqlDataType.Char || dt.SqlDataType == Smo.SqlDataType.NChar || dt.SqlDataType == Smo.SqlDataType.VarChar || dt.SqlDataType == Smo.SqlDataType.NVarChar) { dataType += String.Format("({0})", dt.MaximumLength); } if (!c.Nullable) { dataType += " not null"; } row.Cells["dgcDataType"].Value = dataType; // Display any domain previously associated with the column IColumnDomain cd = Array.Find <IColumnDomain>(curDomains, delegate(IColumnDomain tcd) { return(tcd.ColumnName == c.Name); }); if (cd != null) { row.Cells["dgcDomain"].Value = cd.Domain; } row.Tag = c; } // Nothing initially selected columnsGrid.CurrentCell = null; // If we have a simple primary key, assume it's the feature ID column if (String.IsNullOrEmpty(m_Edit.IdColumnName)) { Smo.Column pk = TableFactory.GetSimplePrimaryKeyColumn(t); if (pk != null) { idColumnComboBox.SelectedItem = pk.Name; } } else { idColumnComboBox.SelectedItem = m_Edit.IdColumnName; } }