Bob
Wed Nov 16 00:33:58 CST 2005
The array of attributes defined must all exist on a given property so you
may use a combination of Appearance and Browsable but not a combination of
Appearance and Layout.
The code after my signature demonstrates...
--
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting
http://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
PropertyDescriptorCollection
pdc=TypeDescriptor.GetProperties(typeof(Control),new Attribute[]{new
CategoryAttribute("Appearance"),new BrowsableAttribute(true)});
foreach(PropertyDescriptor pd in pdc)
System.Diagnostics.Trace.WriteLine(pd.Name);
pdc=TypeDescriptor.GetProperties(typeof(Control),new Attribute[]{new
CategoryAttribute("Layout"),new BrowsableAttribute(true)});
foreach(PropertyDescriptor pd in pdc)
System.Diagnostics.Trace.WriteLine(pd.Name);
"JezB" <jezbroadsword@blueyonder.co.uk> wrote in message
news:%23pVyUNe6FHA.2524@TK2MSFTNGP10.phx.gbl...
> Thanks, I see what you mean but can't get the syntax quite right. How do
> you specify the array of attributes and restrict the CategoryAttribute to
> "Appearance" and "Layout" ? I can't find an example.
>
> "Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
> news:%23ixifnd6FHA.3136@TK2MSFTNGP09.phx.gbl...
>> You can use the TypeDescriptor.GetProperties object to obtain a list of
>> properties. Along with this you can also specify an array of attributes
>> that should be taken into consideration. This is how the PropertyGrid
>> obtains only those properties having the Browsable(True) attribute set.
>>
>> In the array of attributes you should include a CategoryAttribute with
>> the name "Appearence" if you want the properties in that section.
>>
>> --
>> Bob Powell [MVP]
>> Visual C#, System.Drawing
>>
>> Ramuseco Limited .NET consulting
>>
http://www.ramuseco.com
>>
>> Find great Windows Forms articles in Windows Forms Tips and Tricks
>>
http://www.bobpowell.net/tipstricks.htm
>>
>> Answer those GDI+ questions with the GDI+ FAQ
>>
http://www.bobpowell.net/faqmain.htm
>>
>> All new articles provide code in C# and VB.NET.
>> Subscribe to the RSS feeds provided and never miss a new article.
>>
>>
>>
>>
>>
>> "JezB" <jezbroadsword@blueyonder.co.uk> wrote in message
>> news:Ojo7kVd6FHA.3232@TK2MSFTNGP15.phx.gbl...
>>> Given a generic Control object, how can I iterate through all the
>>> properties exposed by the control ? Different classes of control expose
>>> different properties.
>>>
>>> Ideally I'd like to find all the properties that are exposed within the
>>> "Appearance" and "Layout" categories of the form designer's property
>>> grid.
>>>
>>> I imagine I can do this via reflection but I don't really know where to
>>> start.
>>> Any pointers ?
>>>
>>
>>
>
>