/// <summary> /// Performs actions related to a property edit. Calls PropertyEdited event.</summary> /// <param name="e">Event args</param> protected virtual void OnPropertyEdited(PropertyEditedEventArgs e) { if (PropertyEdited != null) { PropertyEdited(this, e); } }
private void m_propertyGrid_PropertyEdited(object sender, PropertyEditedEventArgs e) { var context = EditingContext.As<IHistoryContext>(); if (context != null) { context.Dirty = true; } }
/// <summary> /// Sets the property value to the new value</summary> /// <param name="owner">Object whose property is set</param> /// <param name="descriptor">Property descriptor</param> /// <param name="value">New property value</param> public static void SetProperty(object owner, PropertyDescriptor descriptor, object value) { try { TypeConverter converter = descriptor.Converter; if (converter != null && value != null && converter.CanConvertFrom(value.GetType())) { value = converter.ConvertFrom(value); } bool notifyChange = false; object oldValue = null; EventHandler <PropertyEditedEventArgs> handler = PropertyEdited; if (handler != null) { oldValue = descriptor.GetValue(owner); notifyChange = !PropertyUtils.AreEqual(oldValue, value); } descriptor.SetValue(owner, value); if (notifyChange) { PropertyEditedEventArgs eventArgs = new PropertyEditedEventArgs(owner, descriptor, oldValue, value); handler(null, eventArgs); } } catch (InvalidTransactionException) { // The transaction needs to be cancelled. throw; } catch (Exception ex) { PropertyErrorEventArgs eventArgs = new PropertyErrorEventArgs(owner, descriptor, ex); PropertyError.Raise(null, eventArgs); if (!eventArgs.Cancel) { Outputs.WriteLine(OutputMessageType.Error, ex.Message); } } }
private void propertyEditingControl_PropertyEdited(object sender, PropertyEditedEventArgs e) { // figure out the index of the row that changed // keep an eye on this, if it gets slow we may need to replace with // a hash lookup int index = 0; foreach (object item in EditingContext.Items) { if (item.Equals(e.Owner)) { // create a new event using the row index OnRowValueChanged(new RowChangedEventArgs(index)); break; } index++; } }
/// <summary> /// Raises the PropertyEdited event and performs custom processing</summary> /// <param name="e">PropertyErrorEventArgs containing event data</param> protected virtual void OnPropertyEdited(PropertyEditedEventArgs e) { PropertyEdited.Raise<PropertyEditedEventArgs>(this, e); }
/// <summary> /// Performs actions related to a property edit. Calls PropertyEdited event.</summary> /// <param name="e">Event args</param> protected virtual void OnPropertyEdited(PropertyEditedEventArgs e) { if (PropertyEdited != null) { PropertyEdited(this, e); } }
/// <summary> /// Sets the property value to the new value</summary> /// <param name="owner">Object whose property is set</param> /// <param name="descriptor">Property descriptor</param> /// <param name="value">New property value</param> public static void SetProperty(object owner, PropertyDescriptor descriptor, object value) { try { TypeConverter converter = descriptor.Converter; if (converter != null && value != null && converter.CanConvertFrom(value.GetType())) { value = converter.ConvertFrom(value); } bool notifyChange = false; object oldValue = null; EventHandler<PropertyEditedEventArgs> handler = PropertyEdited; if (handler != null) { oldValue = descriptor.GetValue(owner); notifyChange = !PropertyUtils.AreEqual(oldValue, value); } descriptor.SetValue(owner, value); if (notifyChange) { PropertyEditedEventArgs eventArgs = new PropertyEditedEventArgs(owner, descriptor, oldValue, value); handler(null, eventArgs); } } catch (InvalidTransactionException) { // The transaction needs to be cancelled. throw; } catch (Exception ex) { PropertyErrorEventArgs eventArgs = new PropertyErrorEventArgs(owner, descriptor, ex); PropertyError.Raise(null, eventArgs); if (!eventArgs.Cancel) Outputs.WriteLine(OutputMessageType.Error, ex.Message); } }