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

Hiding a row in a PropertyGrid

P: n/a
Is it possible to hide a row within a PropertyGrid based upon the boolean
value of another row within the PropertyGrid? I am using VS2005 with .NET
Frameworks 2.0.

--
-----------
Thanks,
Steve
Jul 12 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hello SteveT,

see this discussion: http://www.dotnet247.com/247referenc...33/165462.aspx
Is it possible to hide a row within a PropertyGrid based upon the
boolean value of another row within the PropertyGrid? I am using
VS2005 with .NET Frameworks 2.0.

Jul 12 '07 #2

P: n/a
Hi Steve,

This is not a trivial task. PropertyGrid exposes no interfaces to
manipulate its UI by removing/adding rows. Normally, PropertyGrid will use
Reflection to query the type/value on the SelectedObject and display one
property for a row. There is no easy way to tell PropertyGrid not to
display any row or add one row. PropertyGrid is not designed with this
function.

If you really want to achieve this task, one workaround is hooking into the
Reflection process of PropertyGrid during querying the object types/values.
Before PropertyGrid queries the properties, it will first query if the
object implement ICustomTypeDescriptor interface. So we can use this
interface as a hook to dynamically add/remove properties.
The codeproject article below demonstrates this technology:
"Add (Remove) Items to (from) PropertyGrid at Runtime"
http://www.codeproject.com/cs/miscct...opertygrid.asp

Note: this technology needs the modification to the selected object instead
of the PropertyGrid class.

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 12 '07 #3

P: n/a
Actually - I seem to recall that you can do this by adding a custom
property-tab and simply tweaking the PropertyDescriptorCollection;
various examples on the net... removing is simpler... to add you need
to create your own PropertyDescriptor. Plenty of examples of that
also.

Marc
Jul 12 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.