1 Attachment(s)
How can I integrate usercontrol's properties into form's properties?
Greetings to everyone!!! :wave:
I have create a custom form and a UserControl which acts like custom form's title bar. What I want to achieve, is to integrate UserControl's properties into custom form's properties. Something like nested properties. Something like this...
Attachment 158961
In this case we have Button's properties integrated into TextBox's properties. Any idea how can I do that?
Thank you in advance!!!
Re: UserControl's properties into Form's properties at Properties Window as new categ
Do you have an example of where something similar has already been done?
Re: UserControl's properties into Form's properties at Properties Window as new categ
Yes, something like the image at my first post!!!
Re: UserControl's properties into Form's properties at Properties Window as new categ
Anybody? I changed my question a bit, please take a look at my first post!!!
Re: How can I integrate usercontrol's properties into form's properties?
Not sure about a usercontrol, but it's possible with a component... the ToolTipComponent does it by adding a ToolTipText property to each of the controls on the form. So it should certainly be possible... HOW it's done though... I don't know....
-tg
Re: How can I integrate usercontrol's properties into form's properties?
Quote:
Originally Posted by
techgnome
Not sure about a usercontrol, but it's possible with a component... the ToolTipComponent does it by adding a ToolTipText property to each of the controls on the form. So it should certainly be possible... HOW it's done though... I don't know....
-tg
That is done by implementing the IExtenderProvider interface, an example of which you can find in my CodeBank thread about Simulating Control Arrays In VB.NET. If you take a look at the screenshot though, I don't think that that's the aim.
All you need to do is add a ReadOnly property that exposes a child control on your user control. I just created a new WinForms project, added a user control, added a Button to the user control and then added this code:
vb.net Code:
Imports System.ComponentModel
Public Class UserControl1
<Category("Metro Appearance")>
Public ReadOnly Property CustomButton As Button
Get
Return Button1
End Get
End Property
End Class
When I added an instance of that user control to the form and opened the Properties window, I saw pretty much exactly what you show in post #1, i.e. a Metro Appearance section with a CustomButton property that could be expanded to show all the properties of that child control.