Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / September 2005

Tip: Looking for answers? Try searching our database.

User controls in VB.NET

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sonali_reddy123@yahoo.com - 15 Sep 2005 15:33 GMT
Hi,

I need a help regarding use of a user defined control in VB.NET.
I could able to prepare a user control and add it to my project
toolbox but the problem is how to pass the data from the application to
the events on the user control.

I found get and set methods do these two methods satisfy the entire
need or is their anything more I should know.

Sample example will be a better response.

Thanks in advance.
Phill.  W - 15 Sep 2005 16:04 GMT
> I need a help regarding use of a user defined control in VB.NET.
. . .
> how to pass the data from the application to the events on the user
> control.

You don't pass data /to/ events.
Use properties (Get and Set) to pass data into the UserControl,
then "handle" the events raised /by/ the UserControl back your
"main" application.  Over-simplifying this:

Class MyUserControl
   . . .
   Public Event X_Changed()
   . . .
   Public Property X() as Integer
       Get
           Return m_iX
       End Get
       Set( Value as Integer )
           m_iX = Value
           RaiseEvent X_Changed
       End Set
   End Property
   Private m_iX as Integer = 0
End Class

Class Form1
   Friend WithEvents uc1 as MyUserControl
   . . .
   Private Sub Button1_Click( _
     byVal sender as Object _
   , ByVal e as EventArgs _
   ) Handles uc1.Button1_Click

       uc1.X = 99

   End Sub

   Private Sub uc1_X_Changed( _
     byVal sender as Object _
   , ByVal e as EventArgs _
   ) Handles uc1.X_Changed
       MsgBox "Something changed X"
   End Sub
End Class

HTH,
   Phill  W.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.