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.