Results 1 to 6 of 6

Thread: How can I integrate usercontrol's properties into form's properties?

  1. #1

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

    How can I integrate usercontrol's properties into form's properties?

    Greetings to everyone!!!

    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...

    Name:  dyDmwey.gif
Views: 242
Size:  23.2 KB

    In this case we have Button's properties integrated into TextBox's properties. Any idea how can I do that?

    Thank you in advance!!!
    Last edited by Simonetos The Greek; May 11th, 2018 at 06:17 AM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

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

    Re: UserControl's properties into Form's properties at Properties Window as new categ

    Yes, something like the image at my first post!!!
    Last edited by Simonetos The Greek; May 11th, 2018 at 06:21 AM.

  4. #4

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

    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!!!
    Last edited by Simonetos The Greek; May 11th, 2018 at 06:18 AM.

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How can I integrate usercontrol's properties into form's properties?

    Quote Originally Posted by techgnome View Post
    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:
    1. Imports System.ComponentModel
    2.  
    3. Public Class UserControl1
    4.  
    5.     <Category("Metro Appearance")>
    6.     Public ReadOnly Property CustomButton As Button
    7.         Get
    8.             Return Button1
    9.         End Get
    10.     End Property
    11.  
    12. 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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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