• Welcome to Valhalla Legends Archive.
 

Usercontrol Question

Started by Anubis, June 11, 2004, 07:53 PM

Previous topic - Next topic

Anubis

It's been a long day and I can't seem to remember...

How can I call something like the Visible property inside a usercontrol from a module or form? My usercontrol is named HC.

Thanks

Eli_1

#1
Quote from: Anubis on June 11, 2004, 07:53 PM
It's been a long day and I can't seem to remember...

How can I call something like the Visible property inside a usercontrol from a module or form? My usercontrol is named HC.

Thanks

Do you mean something like this?


Form1.HC.Visible = False



Anubis

Quote from: Eli_1 on June 11, 2004, 07:57 PM

Form1.HC.Visible = False


Oh, I mean when I'm creating an ocx from the usercontrol. So it won't be on the form/module in the usercontrol's project. I've found that HC.Visible = True doesn't seem to do anything. I've also tried usercontrol.Visible, same with usercontrol1.Visible...

Eli_1

#3
Oops.  ::)


Is this what you're looking for?
Taken from:

http://support.microsoft.com/?kbid=183691

Quote
Workaround
To workaround this problem, you can have the UserControl pass a reference to itself on the Form by a procedure. The following steps illustrate this solution.

1.) Create an ActiveX Control project.
2.) Click Add Form on the Project menu to add a form to the project.
3.) Add the following code to the UserControl:      

Public CtlProp As String 'user created property

     Private Sub UserControl_Click()
         CtlProp = "passed value" 'set the property
         Load Form1
         Call Form1.ControlRef(Me) 'pass the reference before showing
         Form1.Show
     End Sub

     Private Sub UserControl_Initialize()
         BackColor = vbRed
     End Sub

                  
Add the following code to the Form:
      Dim cCtl As UserControl1

     Private Sub Form_Activate()
         MsgBox cCtl.CtlProp 'this works fine now
     End Sub

     Sub ControlRef(cC As UserControl1)
         Set cCtl = cC
     End Sub

Anubis

Quote from: Eli_1 on June 11, 2004, 08:08 PM
Oops.  ::)


Is this what you're looking for?
http://support.microsoft.com/?kbid=183691

Ah, yes. Exactly what I'm looking for. Thanks :)

Anubis

Well, just a quick question. One of my main reasons for needing this is so I can use RaiseEvent from a form/module. Is there any way I can do this from a form/module instead of a usercontrol?