private void PropertyGridRowDeleted(object sender, DataRowChangeEventArgs e) { try { EntitySpaces.MetadataEngine.Single o = e.Row.Table.ExtendedProperties["EntitySpaces.MetadataEngine.Single"] as EntitySpaces.MetadataEngine.Single; if (o != null) { try { DataTable dt = e.Row.Table; dt.RowChanged -= new DataRowChangeEventHandler(this.PropertyGridRowChanged); dt.RowDeleting -= new DataRowChangeEventHandler(this.PropertyGridRowDeleting); dt.RowDeleted -= new DataRowChangeEventHandler(this.PropertyGridRowDeleted); dt.AcceptChanges(); dt.RowChanged += new DataRowChangeEventHandler(this.PropertyGridRowChanged); dt.RowDeleting += new DataRowChangeEventHandler(this.PropertyGridRowDeleting); dt.RowDeleted += new DataRowChangeEventHandler(this.PropertyGridRowDeleted); } catch { } } } catch { } }
public void EditSingle(EntitySpaces.MetadataEngine.Single obj, string niceName) { try { this.single = obj; DataTable dt = new DataTable(); DataColumn k = dt.Columns.Add("Key", typeof(string)); k.Unique = true; DataColumn v = dt.Columns.Add("Value", typeof(string)); k.AllowDBNull = false; IPropertyCollection properties = obj.Properties; DataRowCollection rows = dt.Rows; foreach (IProperty prop in properties) { rows.Add(new object[] { prop.Key, prop.Value }); } dt.AcceptChanges(); this.Grid.DataSource = null; this.Grid.DataSource = dt.DefaultView; dt.ExtendedProperties["EntitySpaces.MetadataEngine.Single"] = obj; dt.RowChanged += new DataRowChangeEventHandler(PropertyGridRowChanged); dt.RowDeleting += new DataRowChangeEventHandler(PropertyGridRowDeleting); dt.RowDeleted += new DataRowChangeEventHandler(PropertyGridRowDeleted); } catch { } }
private void PropertyNiceNameLeave(object sender, EventArgs e) { try { this.single = null; } catch { } }
private void PropertyGridRowDeleting(object sender, DataRowChangeEventArgs e) { try { EntitySpaces.MetadataEngine.Single o = e.Row.Table.ExtendedProperties["EntitySpaces.MetadataEngine.Single"] as EntitySpaces.MetadataEngine.Single; if (o != null) { try { this.isDirty = true; o.Properties.RemoveKey(e.Row["Key"] as string); } catch { } } } catch { } }
private void PropertyGridRowChanged(object sender, DataRowChangeEventArgs e) { try { EntitySpaces.MetadataEngine.Single o = e.Row.Table.ExtendedProperties["EntitySpaces.MetadataEngine.Single"] as EntitySpaces.MetadataEngine.Single; if (o != null) { try { string sKey = e.Row["Key"] as string; if (sKey == null || sKey.Length == 0) { MessageBox.Show("Requires a 'Key' or this record won't be saved"); return; } string sValue = e.Row["Value"] as string; if (sValue == null || sValue.Length == 0) { MessageBox.Show("Requires a 'Value' or this record won't be saved"); return; } IProperty p = o.Properties[sKey]; if (p != null) { p.Value = sValue; } else { o.Properties.AddKeyValue(sKey, sValue); } this.isDirty = true; } catch { } } } catch { } }