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;
         }
     }

    }
}

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

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;
         }
     }

    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.