How to fire an event on form close | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to fire an event on form close

I think I'm missing something in the syntax. I have two win forms. One is Login and the other is Main. Upon successful login, Login form gets hidden and Main is shown. When I quit the Main, Login is still active in the background so the app is still running. How to fire an Application.Exit() when Main gets closed, I've tried a bunch of functions but none seem to do the trick?

23rd Apr 2017, 9:21 PM
Miloš
Miloš - avatar
4 Answers
+ 8
that mean to: login form for button "OK" put: me.hide() mainform.show() mainform for button "Close" put: me.close()
24th Apr 2017, 1:19 AM
Mohammad Dakdouk
Mohammad Dakdouk - avatar
+ 7
did you try to put in the login form main.show() me.hide()
23rd Apr 2017, 10:17 PM
Mohammad Dakdouk
Mohammad Dakdouk - avatar
+ 7
if you are using visual basic in the login form this code will work me.hide() Mainform.show() you can use "me.close()" in the Mainform and it will close the application. this.hide() // this is not defined in visual basic
24th Apr 2017, 1:12 AM
Mohammad Dakdouk
Mohammad Dakdouk - avatar
0
No, it's called from Login form - on button click if user / pass OK then this.hide MainForm.show But I don't know what is the event that is triggered when I close the Main form, so I can put Application.Exit() inside it.
23rd Apr 2017, 11:04 PM
Miloš
Miloš - avatar