471,319 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

Force property update in propertygrid

I was wondering if there is a way to force a property within a property grid
to update and then display a modified value when when a second property
(true/false) is toggled?
--
Steve
Dec 16 '05 #1
3 11115
Steve,

In .NET 1.1 and before, you want to create an event of type EventHandler
named <property>Changed. You would then fire this event after you set the
property (internally, so that a call to the get accessor of the property
will return the new value).

In .NET 2.0 and above, you can do as mentioned previously, and you can
also implement INotifyPropertyChanged interface, which has one member, an
event that is fired when the property changes.

When the property changes, you can fire this event and indicate which
property changed.

The property grid will detect this, and then update itself accordingly.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Steve Teeples" <St**********@discussions.microsoft.com> wrote in message
news:80**********************************@microsof t.com...
I was wondering if there is a way to force a property within a property
grid
to update and then display a modified value when when a second property
(true/false) is toggled?
--
Steve

Dec 16 '05 #2
Nicholas, thank you. This did the trick. I had to add another event for the
property grid that actually updated the property visually when a
PropertyValueChanged event occurred. Without it, I only know the string was
being updated when I would click its property in the grid.
--
Steve
"Nicholas Paldino [.NET/C# MVP]" wrote:
Steve,

In .NET 1.1 and before, you want to create an event of type EventHandler
named <property>Changed. You would then fire this event after you set the
property (internally, so that a call to the get accessor of the property
will return the new value).

In .NET 2.0 and above, you can do as mentioned previously, and you can
also implement INotifyPropertyChanged interface, which has one member, an
event that is fired when the property changes.

When the property changes, you can fire this event and indicate which
property changed.

The property grid will detect this, and then update itself accordingly.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Steve Teeples" <St**********@discussions.microsoft.com> wrote in message
news:80**********************************@microsof t.com...
I was wondering if there is a way to force a property within a property
grid
to update and then display a modified value when when a second property
(true/false) is toggled?
--
Steve


Dec 17 '05 #3
tlhintoq
3,525 Expert 2GB
I know this is an OLD thread, but for the next person looking for a response this works quite well for me:

Expand|Select|Wrap|Line Numbers
  1. object Temp = propertyGrid1.SelectedObject;
  2.                 propertyGrid1.SelectedObject = null;
  3.                 propertyGrid1.SelectedObject = Temp;
Feb 26 '10 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Chris Dunaway | last post: by
4 posts views Thread by John Lafrowda | last post: by
3 posts views Thread by Lance | last post: by
reply views Thread by Tom Shelton | last post: by
reply views Thread by =?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.