Results 1 to 4 of 4

Thread: UserControl and its properties

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2001
    Posts
    2

    UserControl and its properties

    Hello,

    I'm creating an usercontrol. Now i want to create some properties for it, and i'm wondering if the following can be accomplished:

    usercontrol.props.add()

    I can create it like this:

    usercontrol.add()


    This is what i have as code:

    Code:
    Public type item
      prop1 as string
      prop2 as string
    end type
    
    public property get test() as item
    'code
    end property
    
    public property let test(vNewValue as item)
    'code
    end property
    
    Public sub Add()
    'code
    end sub
    Can anyone tell me, what i have to do to make the sub Add() as a property of Item??

    Thanx,
    Barry

  2. #2
    Fanatic Member Bonker Gudd's Avatar
    Join Date
    Mar 2000
    Location
    Saturn
    Posts
    748
    You would use the same syntax as for your test Property to create another Proprety.
    I don't know anyway to create something like usercontrol.props.add().
    I'd just set your strings in a Property.

    If you add public Subs/Functions, then these are like methods for your control.

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2001
    Posts
    2
    Can you give me some more info please? i don't what you mean.

    Barry

  4. #4
    Fanatic Member Bonker Gudd's Avatar
    Join Date
    Mar 2000
    Location
    Saturn
    Posts
    748
    At the top of the code, define prop1 to be modular variable:
    VB Code:
    1. Private m_prop1 As String
    to set prop1:
    VB Code:
    1. public property let Prop1(vNewValue as String)
    2.     m_prop1 = vNewValue
    3. end property
    So prop1 is read-only, if you want it to be read/write then add:
    Code:
    public property get Prop1() as String
        Prop1 = m_prop1
    end property
    I like paraffin by the way!

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