class object properties
-
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
-
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
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
-
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
-
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.
-
What is the difficulty if all properties are shown? Finding only the ones you actually neeed (=your own properties)?
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
-
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
-
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?
-
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
-
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
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