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 / .NET Framework / Interop / February 2007

Tip: Looking for answers? Try searching our database.

Event not firing on runtime new instance of form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bidalah@yahoo.com - 16 Feb 2007 20:17 GMT
Hello all,

I am firing an event on one form that is getting handled on another.
Following is my basic code:
__________________________________________

ON FORM #1:

Public WithEvents A_Form2 As New FORM2

Try
       A_Form2.Show()
Catch ex As Exception
       Dim A_Form2 As New FORM2
       A_Form2.Show()
End Try

Private Sub MaketheChanges() Handles A_Form2 .MakeChanges
End Sub
________________________________________________

ON FORM2
Public Event MakeChanges()

Private Sub Save_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
          RaiseEvent MakeChanges()
End Sub
_______________________________________________

This code is working perfectly when I first start the program.  But if
I close A_Form2 and then reopen it, the event won't fire.  I can
understand why.  When I create a new instance of FORM2, I am simply
writing "Dim", rather than "Public WithEvents".  The problem is that I
can't figure out away to declare a new instance of a form withevents
at runtime.  Everything I try gets an error.  Does anyone know how to
do this or even if it is possible?

Please let me know.
Christian Fröschlin - 19 Feb 2007 08:13 GMT
> Catch ex As Exception
>         Dim A_Form2 As New FORM2

No need to declare a new variable just to create a new object instance.
Replacing this with "A_Form2 = New FORM2" should work.
bidalah@yahoo.com - 22 Feb 2007 16:30 GMT
> > Catch ex As Exception
> >         Dim A_Form2 As New FORM2
>
> No need to declare a new variable just to create a new object instance.
> Replacing this with "A_Form2 = New FORM2" should work.

Ofcourse.  Thank you.

Rate this thread:







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



©2008 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.