When the PropertyValueChanged
event is raised, it has an associated PropertyValueChangedEventArgs
object. This object has a ChangedItem
member that holds the GridItem
that was changed.
So if you want to do something with the changed item, your handler could look like:
private void OnPropertyValueChanged(Object sender, PropertyValueChangedEventArgs args) { Console.WriteLine($"The changed item was {args.ChangedItem}"); }
This seems to do the job:
e.ChangedItem.GetType().GetProperty("Instance").GetValue(e.ChangedItem)
you could try:
var obj = (sender as propertyGrid1).SelectedObject;