0

can anyone help me...
the problem is that i want to hide a form when i click the button log out and show the log in form since you just log out and not close the form. but it does not happen...

here's my code...

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading.Tasks;

namespace WindowsFormsApplication3pmp
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }
   private void logOutToolStripMenuItem_Click(object sender, EventArgs e)
     {        
             DialogResult msgbox = new DialogResult();
             MessageBox.Show("Are you sure you want to Log out?", "Log Out", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         {  
             if (msgbox == System.Windows.Forms.DialogResult.Yes)
             {
                 this.Hide();
                 new LogIn ().Show();
             }
             else if (msgbox == System.Windows.Forms.DialogResult.No)
                 return;
         }
     }

    }
}
2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by rockout15
0

Do you have any more information? Does the current form hide but the log in form not display? Does nothing happen at all?

0

haha.. too funny i found out the answer to my question.. the code should go like this..

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading.Tasks;

namespace WindowsFormsApplication3pmp
{
    public partial class MainForm : Form
    {
         DialogResult msgbox = new DialogResult();
        public MainForm()
        {
            InitializeComponent();
        }
   private void logOutToolStripMenuItem_Click(object sender, EventArgs e)
     {     
            msgbox = MessageBox.Show("Are you sure you want to Log out?", "Log Out", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         {  
             if (msgbox == System.Windows.Forms.DialogResult.Yes)
             {
                 this.Hide();
                 new LogIn ().Show();
             }
             else if (msgbox == System.Windows.Forms.DialogResult.No)
                 return;
         }
     }

    }
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.