Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

[ GDI Development ] #3 : Child Classes

Intro

Custom Child Classes are nearly the most useful assets of GDI projects when it comes to big projects, they can be used in many fields especially for lists.

Q : what the use of child classes ?

- They can be use in many fields like we can use them as and store them a the lists or arrays, the way of using them depends on the developers projects and thoughts.




Let's start this with coding...

Note : we don not need ControlDesigner or DesignerActionLists for this tutorial but you can also use this method with both of them too but We put this into the simplicity.

let's get back into the ControlDesigner Part Here and use the control there without ControlDesigner and DesignerActionList.

Now we grab the control and use it here :


C#.NET

Spoiler (Click to View)




Visual Basic.NET

Spoiler (Click to View)




As you know the control above contains 3 custom properties and they are :

  • ForeColor.

  • BaseColor.

  • BorderColor.



now what I want to show is creating a custom class that we use it as child class and we put all these three properties into it then we use it our control, in other words we move these properites into the custom class then we use it.

let's create a custom class

C#.NET






Visual Basic.NET






as you see above I changed the properties type from Manual Properties to Auto Properties, But why ? cause in this custom class I don't need inheritances but I use this as child , we can also implement INotifyPropertyChanged but we don't need it a bit.

now we're done with the custom class let's head back to the parent which the control and use this classes fields in side a property.

now we create a property

C#.NET






Visual Basic.NET






As you see I declared the child class as property , and I provided an atribute above the property which is TypeConverter which is really important.

Warning : in the case of using child class as in this tutorial without using the below line as property attribute to child class all efforts will turn into nothing, cause our list of child properites in PropertyGrd won't be expandable.

C#.NET

Code
[TypeConverter(typeof(ExpandableObjectConverter))]

Visual Basic.NET

Code
<TypeConverter(GetType(ExpandableObjectConverter))>

now if you used the custom properties in drawing or wherever you should change them like this

Code
ColorScheme.ForeColor




The result of this tutorial

[Image: 5eQbrBm.png]


That was the end of series, I hope these three lessons help the GDI developers in some way, happy coding.
[Image: narwinsig.gif]
I am fucking loving these tutorials you have been posting.

This is something I didn't find very well documented when I was searching and, mainly due to a language barrier, I didn't really know what to search for and thus couldn't find a solution. You answered all the questions regarding custom controls that I have had for a long time. Thanks!
There were a lot of other useful tutorials I wanted to share like the benefit of GraphicsPath(s) especially when it comes to hovering complicated shapes but because of the lack of time I shorted the series into 3 leasons, btw glad that helped.
[Image: narwinsig.gif]
Am really glad to see those three lessons i really wished to have more of your great lessons ,anyways thanks for sharing mate.
I don't mean to be the guy who takes a shit on a HQ thread because of a technicality, but personally I wouldn't have used term "child class" since the class in the tutorial isn't actually a child. It's just a bit misleading.
(Sep 10, 2017 11:48 AM)Hawk HF Wrote:  I don't mean to be the guy who takes a shit on a HQ thread because of a technicality, but personally I wouldn't have used term "child class" since the class in the tutorial isn't actually a child. It's just a bit misleading.

As long as they are not the main classes we can call them the chlid classes, they don't need to be just in the same class to call them child , but I don't much care about the grammer stuff about this you can call them anything you want.
[Image: narwinsig.gif]
(Sep 10, 2017 12:17 PM)Narwin Wrote:  As long as they are not the main classes we can call them the chlid classes, they don't need to be just in the same class to call them child , but I don't much care about the grammer stuff about this you can call them anything you want.

But it doesn't inherit from anything. ❓
(Sep 10, 2017 12:46 PM)Hawk HF Wrote:  But it doesn't inherit from anything. ❓

This.
I thought this was something with Tabcontrols but not and I agree more with Hawk. This tutorial doesn't show the meaning of a "Child" class.
Anyway, still a high quality stuff. Good job. 🤝


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by ๖ۣۜMephobiaNov 14, 2025 07:54 PM 171 21,478 Nov 14, 2025 07:54 PM
Last Post: ProxyLand
[.NET] by QuobiAug 6, 2022 02:23 PM 0 407 Aug 6, 2022 02:23 PM
Last Post: Quobi
[.NET] by PolarisGangJun 21, 2022 10:09 AM 1 353 Jun 21, 2022 10:09 AM
Last Post: gigajew