public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { List <IndexColumn> ic = value as List <IndexColumn>; Index index = ic[0].OwningIndex; Table t = index.Table; IndexColumnEditorDialog dlg = new IndexColumnEditorDialog(ic); DialogResult result = dlg.ShowDialog(); if (index.Type != IndexType.Primary) { return(value); } foreach (Column c in t.Columns) { c.PrimaryKey = false; } foreach (IndexColumn i in ic) { i.OwningIndex = index; foreach (Column c in t.Columns) { if (c.ColumnName == i.ColumnName) { c.PrimaryKey = true; } } } t.NotifyUpdate(); return(value); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { List<IndexColumn> ic = value as List<IndexColumn>; Index index = ic[0].OwningIndex; Table t = index.Table; IndexColumnEditorDialog dlg = new IndexColumnEditorDialog(ic); DialogResult result = dlg.ShowDialog(); if (index.Type != IndexType.Primary) return value; foreach (Column c in t.Columns) c.PrimaryKey = false; foreach (IndexColumn i in ic) { i.OwningIndex = index; foreach (Column c in t.Columns) if (c.ColumnName == i.ColumnName) c.PrimaryKey = true; } t.NotifyUpdate(); return value; }