Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / October 2007

Tip: Looking for answers? Try searching our database.

PropertyGrid: CategoryAttribute + BrowsableAttributes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marco Segurini - 12 Oct 2007 13:45 GMT
Hi All,

I have a form containing only a PropertyGrid that I use to modify an
instance of the following class:

   class MyClass
   {
      Point _point = new Point();

      [CategoryAttribute("Drawing")]
      public Point MyPoint
      {
         get { return _point; }
         set { _point = value; }
      }
   }

All works fine.

Now if I add

   this._propertyGrid.BrowsableAttributes
      = new AttributeCollection(
            new Attribute[] { new CategoryAttribute("Drawing") });

to the form's initialization code: what happens is that "MyPoint"
property does not more expand in the PropertyGrid.

Is there a way to apply the CategoryAttribute only to the first level of
properties?

TIA.
Marco.
VisualHint - 12 Oct 2007 15:44 GMT
Hello Marco,

I guess that you are trying to show only properties (and their
subproperties) that are under a particular category. Unfortunately you
are not using the right tool to do that. Your subproperties get
filtered because they don't have the CategoryAttribute you supply. A
better way would be to use a TypeDescriptor or TypeConverter for your
class that would filter out any toplevel property that is not under
the category (it would publish only the PropertyDescriptors that have
the CategoryAttribute).

Best regards,

Nicolas Cadilhac @ VisualHint (http://www.visualhint.com)
Home of Smart FieldPackEditor.Net / DateTimePicker replacement (http://
www.visualhint.com/index.php/fieldpackeditor)
Home of Smart PropertyGrid for .Net and MFC (http://www.visualhint.com/
index.php/propertygrid)
Microsoft PropertyGrid Resource List - http://www.propertygridresourcelist.com

> Hi All,
>
[quoted text clipped - 29 lines]
> TIA.
> Marco.
Nicholas Paldino [.NET/C# MVP] - 12 Oct 2007 18:08 GMT
Marco,

   Unfortunately, no.  You would have to apply the appropriate attributes
to your parent class (which I can see you not wanting to do, for obvious
reasons).

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> Hi All,
>
[quoted text clipped - 29 lines]
> TIA.
> Marco.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.