Solved

Expose a User control event.

Posted on 2007-03-27
2
552 Views
Last Modified: 2012-06-21
How do I expose an event on a user control.  I have a user control with some textboxes on a form control.  There are some leave events in the usercontrol itself (totaling the textboxes).  Is there a way that I can catch this event from the main form so I preform some other action on the main form?  
0
Comment
Question by:Kevin Robinson
[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 Comments
 
LVL 21

Expert Comment

by:K V
ID: 18799688
well in this can u have to use raiseevent.
and in main form you have to handle/catch this method/event
0
 
LVL 17

Accepted Solution

by:
ZeonFlash earned 500 total points
ID: 18799944
Here's a quick example.  The example UserControl has a single textbox on it that will have it's Leave event relayed back to the main form:

Public Class UserControl1
    Inherits System.Windows.Forms.UserControl

      Public Event TextBoxLeave(ByVal TheTextBox As TextBox)

      Private Sub TextBox1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Leave
            RaiseEvent TextBoxLeave(sender)
      End Sub

End Class

In your main form's code, you can catch the event like this:

      Private Sub UserControl11_TextBoxLeave(ByVal TheTextBox As System.Windows.Forms.TextBox) Handles UserControl11.TextBoxLeave
            MsgBox(TheTextBox.Name & " has thrown the Leave event")
      End Sub
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

623 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