I have a control extending PropertyGrid which allows users to set the properties of some of my program objects. These objects have an event which is raised when one of their properties changes, and the PropertyGrid subscribes to this event so that it refreshes itself when a property is changed. My problem occurs when large numbers of objects are selected, and the user sets a property on all of the objects at once. The control gets swamped with Refresh() requests, which take a long time (for example, setting a property on ~300 objects takes about 20 seconds with the auto-refresh feature turned on, and just a fraction of a second when it is turned off).
I would like to prevent the event handler from refreshing the grid while the property grid is in the process of setting a property, but unfortunately I haven't been able to find any way to determine when the grid "starts" and "stops" setting the property. I was hoping there would be methods or something I could override, such as...
override void OnSetPropertyStart()
{
suppressRefresh = true;
}
override void OnSetPropertyEnd()
{
suppressRefresh = false;
}
Unfortunately this doesn't seem to be the case. Is there any other way to determine when the property grid is setting a property, or to otherwise achieve this same effect?