Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / August 2004

Tip: Looking for answers? Try searching our database.

Forcing properties window to refresh when value changes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mark Conway - 20 Aug 2004 09:55 GMT
I've found an approach to dynamically make items Read only in a property grid
- by using a custom PropertyDescriptor. It appears to work, but with a slight
problem that the property grid doesn't refresh itself when the property
changes. By responding to the PropertyGrid.PropertyValueChanged event by
executig the Refresh() method it works fine.

How do I find the property grid control in the properties window, and add
this event handling to it ?

Or is there a documented way of enabling/disabling properties dynamically ?
"Ed Dore [MSFT]" - 20 Aug 2004 18:50 GMT
Hi Mark,

Are you implementing a VSIP package or an addin here? What object's
properties are you pushing to the properties page?

Thanks,
Ed Dore [MSFT]

This post is 'AS IS' with no warranties, and confers no rights.
Mark Conway - 23 Aug 2004 10:35 GMT
Ed,
I'm writing a managed VSIP package - actually based on the Project sample
that shipped in Beta 1. The sample Project class has a GetNodeProperties()
method that I override to supply my properties object. As far as I can tell,
this is used to return the property, __VSHPROPID.VSHPROPID_BrowseObject on
the IVsProject interface.

As mentioned, I wrap this object with one that implements
ICustomTypeDescriptor, which generates custom PropertyDescriptor's which
override IsReadOnly() to dynamically determine if the property is read only.

So setting one property to "False" might make another property read-only. It
appears that the property grid does go thru and re-evaluate the items (my
IsReadOnly() methods gets called again for each item), but the control
doesn't actually redraw these items grayed & disabed. Using a standard
property grid, Refresh() causes it to redraw correctly.

I appreciate it's not ideal for a properties object to know anything about
the property grid that's displaying it, and I'd certainly rather it didn't
have to. I looked at whether the PropertyDescriptor, ICustomTypeDescriptor
might get to know about what was using them, but the property grid doesn't
appear to use any notifications (e.g. add itself as a listener to value
changed events), or interestingly use PropertyDescriptor::SetValue() to set
the value.

Being able to dynamically enable/disable controls is very useful, so I'd
very much like to see the property grids support it. If necessary, I'm happy
to publish some sample code. If there's an easier way to do it than my
approach, I'd very much like to know.

Thanks in advance

Mark.

> Hi Mark,
>
[quoted text clipped - 5 lines]
>
> This post is 'AS IS' with no warranties, and confers no rights.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.