CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2001
    Posts
    4

    Dynamic property of user control


    I Am developing a user control (Active x control) using Visual Basic.I want to create
    my property which can take say three values.For that it should display A combo box.
    How can i create a combo box for a property.

    Extending this i want to create a property which can be populated when
    initialize event is fired.I want to dynamically populate it.Say i want
    to put all names of controls which are present in the form
    in that list.How can i do this.






  2. #2
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: Dynamic property of user control

    <de-lurk>

    You can add your own 'Enumerations' for the property window using the Enum keyword in VB when defining a 'type', eg - paste this into a new user control :


    option Explicit
    '
    public Enum YourType
    TypeOne
    TypeTwo
    TypeThree
    End Enum
    '
    private mMember as YourType
    '
    public property let Member(byval yt as YourType)
    ' fill in the blanks here
    End property
    '
    public property get Member() as YourType
    ' fill in the blanks here
    End property




    If you then added this control to a form and looked at the property window, you'll see the 'Member' property now has a dropdown with the three values available from the enumeration

    </de-lurk>


    Chris Eastwood
    VBCodeLibrary - http://www.vbcodelibrary.com

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

Featured