Notification texts go here Contact Us Buy Now!

How can I get a reference to the object changed in a PropertyValueChanged event?

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;

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.