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

    Property on UserControl

    Hi, guys !
    I have an ActiveX control with a single Usercontrol that have a button calling a Form.
    In that form, I want to set an property on UserControl, but I dont´t know how to do it !
    How can I refer the user control in the form ?
    How can I do that form to set a property on UserControl ?...


  2. #2
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: Property on UserControl

    One way is to give the form your calling a property which contains a reference to the usercontrol so your button click might look like:



    private Sub Button_Click()
    set form1.ownercontrol = usercontrol
    form1.show
    end sub





    then your form could reference it like:


    me.ownercontrol.(whateveryouneedtodohere....)





  3. #3
    Join Date
    May 2001
    Location
    Canada
    Posts
    182

    Re: Property on UserControl

    Hi,

    I did a smiple test as following. The property on the UserControl is TestName, and I can refer it on the test form.

    ============
    'in the Active Control form

    Option Explicit
    Private mstrName As String

    Private Sub Command1_Click()
    MsgBox "Hello"
    End Sub

    Public Property Let TestName(strName As String)

    mstrName = strName

    End Property


    Public Property Get TestName() As String

    TestName = mstrName

    End Property

    ===
    'In the test from

    Private Sub Form_Load()
    UserControl11.TestName = "aaa"
    End Sub

    =======

    Regards,

    Michi

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