.NETGURU
Detect Form Closing
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.windowsforms.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Derek Hart
I have a main form that is open by using: Application.Run(New
fFormCriteria)

And then I have a form that runs invisible that is open by using: Dim
myForm As New fVersionTimer

The fFormCriteria form is the form that the user will close to exit the
program. How do I detect the Form_Closing event on frmVersionTimer? Is it
possible?

Derek Hart

Reply to this message...
 
    
Herfried K. Wagner [MVP] (VIP)
* "Derek Hart" <Click here to reveal e-mail address> scripsit:
[Original message clipped]

Use 'AddHandler' to add a handler to the 'fFormCriteria''s 'Closed'
event.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Reply to this message...
 
    
Derek Hart
Why would I have to add a handler? Why doesn't the handler trigger since it
is an event in the form?

Derek Hart

"Herfried K. Wagner [MVP]" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Jeffrey Tan[MSFT] (VIP)
Hi Derek,

You may pass the main form's reference to the hidden form, then in the
hidden form(fVersionTimer), add the closing eventhandler for the main form.
Code like this:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim f2 As New Form2(Me)
End Sub

'In Form2, create a new constructor for passing Form1's reference
Dim p As Form1
Public Sub New(ByVal parent As Form1)
MyBase.New()

Me.p = parent
AddHandler Me.p.Closing, AddressOf ParentForm_Closing
'This call is required by the Windows Form Designer.
InitializeComponent()

End Sub

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub

Private Sub ParentForm_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs)
MessageBox.Show("abc")
End Sub

=======================================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Reply to this message...
 
    
Jeffrey Tan[MSFT] (VIP)
Hi Derek,

Does my reply make sense to you? Is your problem resolved? Please feel free
to tell me. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Reply to this message...
 
 
System.ComponentModel.CancelEventArgs
System.EventArgs
System.Object
System.Windows.Forms.Application
System.Windows.Forms.MessageBox




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification