don't close form except a user is logged in
I have a winform and want to make it unclo开发者_Go百科sable if the user is not logged in ( userLogedIn = false ) and let it close only if the user is logged in ( userLogedIn = true ).
How can i do so ?
You can use the FormClosing event and set e.Cancel to the opposite (!userLoggedIn) of your userLoggedIn value, that will stop the form from closing.
精彩评论