Results 1 to 12 of 12

Thread: Custom Categories and Sub Categories for UserControl's Custom Properties

  1. #1

    Thread Starter
    Lively Member Simonetos The Greek's Avatar
    Join Date
    Mar 2018
    Location
    Athens, Greece
    Posts
    65

    Custom Categories and Sub Categories for UserControl's Custom Properties

    I have create a UserControl and some custom properties for it but I want to group them into a custom category with "sub categories". Something like that.

    Code:
    |+| Custom Category Name
         |+| Custom Sub Category
              |+| My Property
                         My Value1 Header: Value1
                         My Value2 Header: Value2
        OR
    
    |+| Custom Category Name
         |+| Custom Sub Category
                  My Property: Value
    I know how to make custom properties and add them into custom categories, but how can I make sub categories and add my custom properties in?

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Custom Categories and Sub Categories for UserControl's Custom Properties

    You're asking about Expandable Properties. I have a few examples in the MSDN code samples linked to in my signature...

    Edit: It's not a 2 minute process, but the examples are complete

  3. #3

    Thread Starter
    Lively Member Simonetos The Greek's Avatar
    Join Date
    Mar 2018
    Location
    Athens, Greece
    Posts
    65

    Re: Custom Categories and Sub Categories for UserControl's Custom Properties

    Are you talking about this code example?

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Custom Categories and Sub Categories for UserControl's Custom Properties


  5. #5

    Thread Starter
    Lively Member Simonetos The Greek's Avatar
    Join Date
    Mar 2018
    Location
    Athens, Greece
    Posts
    65

    Re: Custom Categories and Sub Categories for UserControl's Custom Properties

    Okay my friend, thank you very much for your time. I'll have to study this code example carefully, it contains small "treasures"!!!

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Custom Categories and Sub Categories for UserControl's Custom Properties

    If you literally are using Size or Point they would automatically be expandable properties, but it takes a little more work to create custom expandable properties

  7. #7

    Thread Starter
    Lively Member Simonetos The Greek's Avatar
    Join Date
    Mar 2018
    Location
    Athens, Greece
    Posts
    65

    Re: Custom Categories and Sub Categories for UserControl's Custom Properties

    Quote Originally Posted by .paul. View Post
    If you literally are using Size or Point they would automatically be expandable properties, but it takes a little more work to create custom expandable properties
    Yes I know that, I have already noticed!!! I am talking about custom properties which I have create, like CustomBackColor, CustomFont and much more and I just want to group them so Properties Window not look so messy. For example, for CustomBackColor custom property, I would like to add a sub category under Appearece, by the name Extra Properties and add CustomBackColor custom property inside!!!
    Code:
    |+| Appearece
         |+| Extra Properties
                 CustomBackColor: Value

  8. #8
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: Custom Categories and Sub Categories for UserControl's Custom Properties

    You can't add sub-categories, in the end that's just as cluttered as not having categories at all. You get one layer of categories, so use it wisely.

    Generally, you don't add a new BackColor property with a different name to a control. Users are used to using BackColor, and expect to use that. If what that color does is more specific, give it a name that says what it does.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  9. #9

    Thread Starter
    Lively Member Simonetos The Greek's Avatar
    Join Date
    Mar 2018
    Location
    Athens, Greece
    Posts
    65

    Re: Custom Categories and Sub Categories for UserControl's Custom Properties

    Quote Originally Posted by Sitten Spynne View Post
    You can't add sub-categories, in the end that's just as cluttered as not having categories at all. You get one layer of categories, so use it wisely.
    Oh... So in that case I can't do what I want. Except if I create a Form with a PropertyGrid control inside, which will popup in Design Time, when user click on specific Property on Properties Window? Is than an option? Can I do something like that?

    Quote Originally Posted by Sitten Spynne View Post
    Generally, you don't add a new BackColor property with a different name to a control. Users are used to using BackColor, and expect to use that. If what that color does is more specific, give it a name that says what it does.
    I agree!!! CustomBackColor and CustomFont was fake property names, just for example!!!

  10. #10
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: Custom Categories and Sub Categories for UserControl's Custom Properties

    Quote Originally Posted by Simonetos The Greek View Post
    Oh... So in that case I can't do what I want. Except if I create a Form with a PropertyGrid control inside, which will popup in Design Time, when user click on specific Property on Properties Window? Is than an option? Can I do something like that?
    Once you commit to creating a custom property editor, you can basically do whatever you want.

    That process involves implementing some interfaces and applying some attributes I don't quite remember. (I did this for 6 years, but that was 5 years ago.) At a high level, a "UI Editor" for a control is a UserControl that gets a property value and has to publish changes to that value in a particular way. So whatever thing you can imagine is possible.

    But I re-iterate: overcategorization is worse than no categorization. I haven't used the "category" view for years to edit properties, I like them alphabetized so I can get to the ones I want. If your control takes 4 extra clicks to edit some property, I'd much rather use someone else's that takes fewer clicks.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  11. #11

    Thread Starter
    Lively Member Simonetos The Greek's Avatar
    Join Date
    Mar 2018
    Location
    Athens, Greece
    Posts
    65

    Re: Custom Categories and Sub Categories for UserControl's Custom Properties

    Quote Originally Posted by Sitten Spynne View Post
    Once you commit to creating a custom property editor, you can basically do whatever you want.

    That process involves implementing some interfaces and applying some attributes I don't quite remember. (I did this for 6 years, but that was 5 years ago.) At a high level, a "UI Editor" for a control is a UserControl that gets a property value and has to publish changes to that value in a particular way. So whatever thing you can imagine is possible.

    But I re-iterate: overcategorization is worse than no categorization. I haven't used the "category" view for years to edit properties, I like them alphabetized so I can get to the ones I want. If your control takes 4 extra clicks to edit some property, I'd much rather use someone else's that takes fewer clicks.
    Thank you very much for your help and your advices!!! I'll keep them in mind...

  12. #12
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Custom Categories and Sub Categories for UserControl's Custom Properties

    What S and S is recommending is what i showed you in that example...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width