Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do you communicate between two Usercontrols

Posted on 1999-08-28
4
Medium Priority
?
191 Views
Last Modified: 2011-08-18
I am creating an active-x control, and I would like to know how I can call a method,event ect.. from one usercontrol to another usercontrol using (2) usercontrols like
command1_click in first usercontrol would control an event in the second usercontrol!!-

I already tried load (name)  and nothing???

0
Comment
Question by:CindyGraves
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 15

Expert Comment

by:ameba
ID: 1534320
This is possible but this is not good programming practice.
You should use events of your User controls from Container (form)
0
 
LVL 1

Accepted Solution

by:
jdunck earned 320 total points
ID: 1534321
ameba,
  I disagree.  If the UserControls are designed to work together, then it is fine for one control to respond to another controls events.  Think about the ImageList and the PictureBox, TreeView, and such.
 
CindyGraves,
  You'll need to have a procedure or Property Set that is passed the UserControl that you want to trap errors for.


UserControl1:
has a command button, Command1

Public Event UC1Click()

Private Sub Command1_Click()
  RaiseEvent UC1Click()
End Sub


UserControl2:

Dim WithEvents mctlControl as UserControl1

Public Property Set ctlControl(ctlNew as UserControl1)
  Set mctlControl = ctlNew
End Property

Private Sub mctlControl_UC1Click()
  MsgBox "got UserControl1's click"
End Sub


Form1:
Has UserControl1, UserControl2

Private Sub Form_Load()
  Set UserControl2.ctlControl = UserControl1
End Sub


 

0
 
LVL 15

Expert Comment

by:ameba
ID: 1534322
jdunck's answer is technically correct and solves the problem.
Keeping the controls simple and independant is good practice - of course there are exceptions, like ImageList and such (don't know many samples, perhaps Buddy control)
0
 
LVL 1

Author Comment

by:CindyGraves
ID: 1534323
Thank you, for the excellent answer!!

Cindy
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question