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 / Windows Forms / WinForm General / April 2005

Tip: Looking for answers? Try searching our database.

Some questions about PropertyGrid control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
micro_bug - 27 Apr 2005 09:04 GMT
Now I am developing a tool, just like VS.net Form Edition environment.
User can edit a component's properties by a PropertyGrid control.
Now I have some questions about this PropertyGrid control:
1. How to verify a property's validifity?
as you know, In VS.net, when we input a component name that is same with an
existed name in the propertygrid, an error message will pop up: "Invalid
property value".
Now, my question is, how to implement this verification?
Certainly, I can check every property's validifity by handling the event
PropertyValueChanged. But I think it is not so good, because there are so
many properties, and it is a little complicated about logic.
Could you give me a classical solution about this problem?

2. How to change readonly attribute of a property at run time?
As we know, if we want a property to be readonly, we can implement it by
adding an ReadonlyAttribute above the property. But how to changed it at run
time?
In some cases, a property's edition maybe make another property to be
readonly.
So how to create this relationship between properties.

I am a little comfused about propertyGrid control, Could you tell me a good
solution?
Any advice is appreciated.
Thank you.
Dominique Kuster - 28 Apr 2005 12:32 GMT
> 1. How to verify a property's validifity?
> as you know, In VS.net, when we input a component name that is same with an
> existed name in the propertygrid, an error message will pop up: "Invalid
> property value".
Did you try to throw an ArgumentException from the property set function ?

> 2. How to change readonly attribute of a property at run time?
I know one solution that is not really trivial: your class must implement
ICustomTypeDescriptor and you must also derive a new class from
PropertyDescriptor.
Put together you have full control on the behaviour of your object
properties.
Concerning your case, you would override the PropertyDescriptor.IsReadOnly
property.

Rate this thread:







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.