Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. class object properties

class object properties

Scheduled Pinned Locked Moved C#
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    netJP12L
    wrote on last edited by
    #1

    Hi guys, I want to build a class either from Control or UserControl but I don't want to display it's parent properties (Control) inside the PropertyGrid control. I am wondering if there is any easir solution rather than just overriding the parent properties. Thanks

    W V 2 Replies Last reply
    0
    • N netJP12L

      Hi guys, I want to build a class either from Control or UserControl but I don't want to display it's parent properties (Control) inside the PropertyGrid control. I am wondering if there is any easir solution rather than just overriding the parent properties. Thanks

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      Hi, As far as I know, there's no easier way to do this. Also simply overriding isn't enough but you must also apply BrowsableAttribute. If you are trying to make your own properties more easy to find in Properties window, you could use CategoryAttribute to create your own category where your properties are shown. But don't know if this is what you're trying to achieve. Mika

      N 1 Reply Last reply
      0
      • W Wendelius

        Hi, As far as I know, there's no easier way to do this. Also simply overriding isn't enough but you must also apply BrowsableAttribute. If you are trying to make your own properties more easy to find in Properties window, you could use CategoryAttribute to create your own category where your properties are shown. But don't know if this is what you're trying to achieve. Mika

        N Offline
        N Offline
        netJP12L
        wrote on last edited by
        #3

        Actually, I created my a custom button that is derived from the Button class. I just want to display properties that are only defined in my custom class. Currently, it shows all, offcourse. It could have make my life very easir if there is a way to do.

        W 1 Reply Last reply
        0
        • N netJP12L

          Actually, I created my a custom button that is derived from the Button class. I just want to display properties that are only defined in my custom class. Currently, it shows all, offcourse. It could have make my life very easir if there is a way to do.

          W Offline
          W Offline
          Wendelius
          wrote on last edited by
          #4

          What is the difficulty if all properties are shown? Finding only the ones you actually neeed (=your own properties)?

          N 1 Reply Last reply
          0
          • W Wendelius

            What is the difficulty if all properties are shown? Finding only the ones you actually neeed (=your own properties)?

            N Offline
            N Offline
            netJP12L
            wrote on last edited by
            #5

            It's becuase, I do'nt want to display all the properties in my application. Let's say, you have a Rectangle class and it's has the following properties Width, Height Color Name So, why would you want to display all the Control properties inside the PropertyGrid. Another way way i was thinking is to create a data class that olds only the properties and populate the my custom object through that class. And also assign that data class to the PropertyGrid. The bigggest problem will be that for each (Control object) I will have a data class. So, by extending my above example. I created a Field, Player Control(FieldControl.cs, PlayerControl.cs) classes I'll have to have FieldDataClass.cs,PlayerDataClass.cs. if so do you think this may be led me into problems? I appreciated your answers. Thanks

            W 1 Reply Last reply
            0
            • N netJP12L

              It's becuase, I do'nt want to display all the properties in my application. Let's say, you have a Rectangle class and it's has the following properties Width, Height Color Name So, why would you want to display all the Control properties inside the PropertyGrid. Another way way i was thinking is to create a data class that olds only the properties and populate the my custom object through that class. And also assign that data class to the PropertyGrid. The bigggest problem will be that for each (Control object) I will have a data class. So, by extending my above example. I created a Field, Player Control(FieldControl.cs, PlayerControl.cs) classes I'll have to have FieldDataClass.cs,PlayerDataClass.cs. if so do you think this may be led me into problems? I appreciated your answers. Thanks

              W Offline
              W Offline
              Wendelius
              wrote on last edited by
              #6

              You're welcome.

              netJP12L wrote:

              I do'nt want to display all the properties in my application

              So is this actually a run-time problem, not design time? i.e. you're using property grid in your app to let user modify properties?

              N 1 Reply Last reply
              0
              • W Wendelius

                You're welcome.

                netJP12L wrote:

                I do'nt want to display all the properties in my application

                So is this actually a run-time problem, not design time? i.e. you're using property grid in your app to let user modify properties?

                N Offline
                N Offline
                netJP12L
                wrote on last edited by
                #7

                yes that's right. Is there any advice you would like to suggest for my design

                W 1 Reply Last reply
                0
                • N netJP12L

                  yes that's right. Is there any advice you would like to suggest for my design

                  W Offline
                  W Offline
                  Wendelius
                  wrote on last edited by
                  #8

                  Based on the info in your posts I would use data classes as you thought instead of controls directly. It keeps the solution more simple and maintainable. Also use inheritance wherever applicable along with interfaces. Especially if you have common logic based on properties using interfaces and extension methods could be powerful. Mika

                  1 Reply Last reply
                  0
                  • N netJP12L

                    Hi guys, I want to build a class either from Control or UserControl but I don't want to display it's parent properties (Control) inside the PropertyGrid control. I am wondering if there is any easir solution rather than just overriding the parent properties. Thanks

                    V Offline
                    V Offline
                    visualhint
                    wrote on last edited by
                    #9

                    Hi, For the Microsoft PropertyGrid, your control must implement the ICustomTypeDescriptor interface or be associated with a TypeDescriptionProvider (>= .net 2.0). You will find the resources here: http://www.propertygridresourcelist.com/index.php/resources/tag/icustomtypedescriptor/. Basically the GetProperties method will return a PropertyDescriptor only if it comes from your class and remove it if it comes from an ancestor. Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups