By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,225 Members | 2,187 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,225 IT Pros & Developers. It's quick & easy.

Force property update in propertygrid

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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
Expert 2.5K+
P: 3,525
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.