I have two forms .. the form1 is a login form. so if the username and the password typed correctly .. the user will be directed to the form2 and hide form1..
The form2 contain a button "logout" for closing form2 and returning to form1 ..
this is the code for the button logout
private void logout_Click(object sender, EventArgs e)
foreach (Form OpenedForm in Application.OpenForms)
if (OpenedForm is Form1)