PropertyGrid and INotifyPropertyChanged .NET 2.0

S

Stuart Carnie

Does the property grid listen for these events or some other form of notification that a property has changed for a selected object?

My object implements INotifyPropertyChanged, and all other subscribers update except the property grid.

Cheers,

Stu
 
V

VisualHint

Hello Stuart,

INotifyPropertyChanged is definitely not used by the Microsoft
PropertyGrid. But this is a keeper for Smart PropertyGrid.Net. I will
add it right now on my TODO list, maybe for 1.7.

Best regards,

Nicolas Cadilhac @ Visualhint
Smart PropertyGrid for .Net and for MFC
http://www.visualhint.com
 
L

Linda Liu [MSFT]

Hi Stu,

INotifyPropertyChanged interface works in binding scenarioes, which means
change notification would occur in a binding between a bound client and a
data source.

Let's take the DemoCustomer class provided in MSDN document
(http://msdn2.microsoft.com/en-us/library/system.componentmodel.inotifyprope
rtychanged.aspx) for an example. Suppose we have a DemoCustomer instance
and a PropertyGrid control and set the PropertyGrid control's
SelectedObject property to the DemoCustomer instance.

When the values of the properties(CompanyName or PhoneNumber) in the
DemoCustomer instance change, property changed notification won't occur in
this case.

However, if we bind the SelectedObject property of the PropertyGrid control
to the DemoCustomer instance and then change the properties' values of the
DemoCustomer instance at run-time, property changed notification occurs and
the new values are displayed in the PropertyGrid control at once.

The following is a sample code to bind the SelectedObject property of the
PropertyGrid control to a DemoCustomer instance.

DemoCustomer obj = DemoCustomer.CreateNewCustomer();
this.propertyGrid1.DataBindings.Add("SelectedObject", obj, null)

Finally, when we set the PropertyGrid's SelectedObject property to a
business object and want to refresh the properties' values of the selected
object immediately in the PropertyGrid, we could subscribe and handle the
PropertyChanged event of the business object manually. In the event
handler, we call the PropertyGrid.Refresh method to refresh the
PropertyGrid control.

Hope this helps.
If you have anything unclear, please feel free to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top