Change Read/Write Property on Property Grid

C

Carl Gilbert

Hi

Is there any way to enable/disable an item in a property grid at runtime?

I have two properties that I am showin in a property gris and based on the
validity of the first property, I want to disable/enable the second
property. Therefore the user would not be able to set or change the value
of the second property should a tes on the first property fail.

Regards, Carl Gilbert
 
G

Gary Chang[MSFT]

Hi Carl,
Is there any way to enable/disable an item in a property grid at runtime?

From my understanding, I think you want to change the ReadOnly attribute of
the item in a PropertyGrid at runtime, is it?

If so, you are going to use custom PropertyDescriptor class for those
properties, and that class should implement the
"ICustomTypeDescriptor" interface for the usage of the properties of a
PropertyGrid, you can refer to the following group links for the detail
discussion and sample code:
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.window
sforms/browse_thread/thread/1f88a0b456c11af3/439a06cf4ca0aff2?q=propertygrid
+disable+item&_done=%2Fgroups%3Fq%3Dpropertygrid+disable+item%26hl%3Den%26lr
%3D%26sa%3DN%26tab%3Dwg%26&_doneTitle=Back+to+Search&&d#439a06cf4ca0aff2

By the way, another method is enumerating the item you want to disabled,
and clone a new property item(ReadOnly: ture) with it, then remove the old
one and add the new one at run time, you can find many samples how to add
(remove) Items of a PropertyGrid at runtime in the web...


Thanks!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

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