CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 1999
    Posts
    1

    Defining a property

    I am creating a user control. I need to define a property like the List property in the 'Combo' control. i.e. my Get and Let are such that I get a List type property in my user control Property Window. When I define a property as a Boolean it automatically gives me a True and False choice in the Property Window for that property. How do do the same thing for a 'list' type of property or create an enumerated type like the property BorderStyle of a form?

    I would really appreciate if someone can solve this problem

    Thanks
    Irfan


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

    Re: Defining a property

    You cannot do this with standard VB user controls, however, Steve from vbAccelerator (http://www.vbaccelerator.com) has released an amazing type-library that you can compile with your applications to give you the required COM interface in your application.

    Take a look at the page http://www.vbaccelerator.com/codelib...ol/vbalcom.htm - study it very closely so that you understand all of the principles involved before trying to use the code in your program.

    You can also study the examples that come with the type library - there's an example there that does exactly what you're looking for.



    Chris Eastwood

    CodeGuru - the website for developers
    http://www.codeguru.com/vb

  3. #3
    Guest

    Re: Defining a property

    You must define type enum for List in property in Combo control window in declaration section.
    For example:


    public Enum enTest
    enHigh = 0
    enMedium = 1
    enSlow = 2
    End Enum




    This full example code from user defined control:


    'Default property Values:
    Const m_def_TestProperty = 0

    'property Variables:
    public Enum enTest
    enHigh = 0
    enMedium = 1
    enSlow = 2
    End Enum

    Dim m_TestProperty as enTest


    'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
    'MemberInfo=14,0,0,0
    public property get TestProperty() as enTest
    TestProperty = m_TestProperty
    End property

    public property let TestProperty(byval New_TestProperty as enTest)
    m_TestProperty = New_TestProperty
    PropertyChanged "TestProperty"
    End property

    'Initialize Properties for User Control
    private Sub UserControl_InitProperties()
    m_TestProperty = m_def_TestProperty
    End Sub

    'Load property values from storage
    private Sub UserControl_ReadProperties(PropBag as PropertyBag)

    m_TestProperty = PropBag.ReadProperty("TestProperty", m_def_TestProperty)
    End Sub

    'Write property values to storage
    private Sub UserControl_WriteProperties(PropBag as PropertyBag)

    Call PropBag.WriteProperty("TestProperty", m_TestProperty, m_def_TestProperty)
    End Sub





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