Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
When to build a PropertyGrid to have a porperty table for an object class,
normally we have to write attribute for property item in object class, and now, I would dynamically change one of property to have different attribute setting, such as from BrowsableAttribute(true) to be BrowsableAttribute(false),in run-time, how can I reach this goal ? Is there any sample code for reference ? Thanks.
Posted

1 solution

Enabling/disabling properties at runtime in the PropertyGrid[^]
Check this, try something, and come back if there's any problem. :thumbsup:
 
Share this answer
 
Comments
Sports Kuo 21-Feb-11 5:48am    
=====================================
Thanks of your comments, I'll try it and if any problem will let you know at once.
Prerak Patel 21-Feb-11 5:51am    
You are welcome
Sports Kuo 23-Feb-11 3:27am    
========================================
If I would like to change the attribute from "ReadOnlyAttribute" to be "BrowsableAttribute", then what should I do, especially for the string of "isReadOnly" ? Thanks.
Prerak Patel 23-Feb-11 5:13am    
You should try using "Browsable" instead of "isReadOnly"
Sports Kuo 23-Feb-11 6:10am    
=======================================
The 'ReadOnly' setting works fine. Thanks.
And I would change it to be Browsable attribute.
I add "[BrowsableAttribute(true)]" and [BrowsableAttribute(false)" in front of public porperty, and substitue all "ReadOnlyAttribute" with "BrowsableAttribute" in your main lines, now, the string of "isReadOny" is changed to be "Browsable", but it still can not work, I find the fieldToChange is null, so the string "Browsable" seems be without matching, could you find any root cause ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900