Alex
Alex

Reputation: 11147

don't close form except a user is logged in

I have a winform and want to make it unclosable 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 ?

Upvotes: 0

Views: 157

Answers (1)

Daniel Frear
Daniel Frear

Reputation: 1459

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.

Upvotes: 3

Related Questions