Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8776355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:01:58+00:00 2026-06-13T19:01:58+00:00

In my project, there are two forms frmLogin and frmMain . After successful login

  • 0

In my project, there are two forms frmLogin and frmMain. After successful login from frmLogin I am showing the frmMain form to the user by doing something like this:

In frmLogin form button_click event:

frmMain main = new frmMain();
main.Show();
this.Hide();

In frmMain when the user logs out I want to show the same frmLogin form (not the instance). How to do this?

I tried this code: (creating another instance of frmLogin which I don’t want)

In frmMain form button_click event:

if (MessageBox.Show("Do you really want to log out?", "Alert", MessageBoxButtons.YesNo).Equals(DialogResult.Yes))
{
    this.FormClosing -= frmMain_FormClosing;
    //
    Process p = new Process();
    p.StartInfo.FileName = Application.ExecutablePath;
    p.Start();
    //
    this.Dispose();
}

I have also tried using internal specifier but no use.

EDIT: As a trainee, I am not allowed to use Static keyword and altering program.cs. If the above approach requires restricted methods (which I have mentioned) then please suggest me an alternate approach.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T19:01:59+00:00Added an answer on June 13, 2026 at 7:01 pm

    All what you have to do is assign login page as owner of nextform to be opened

    In your login Page call following function where you want to open nextForm

    void openNextForm()
    {
        Form f2 = new YourForm();    
        f2.owner=this;
        f2.Show();
        this.Hide();
    }
    

    In your nextForm (e.g mainForm) write following aginst your button click

    void ButtonLogOut_Click(object sender, EventArgs e)
    {
         this.Owner.Show();
         this.Hide();
         this.Dispose();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Hudson to build my project from my Mercurial repository. There are two
In a .net project, create two forms {Form1, Form2} and on each form create
I've got Windows Forms project. There's a textBox on the form, called txt. The
I have two forms in my project (Login and Main). What I'm trying to
There are two forms in my project and I am trying to add the
There is two Forms in my project : Form1 and Form2. There is a
There are two project in which I collaborate, they live in different servers, A
There are two projects: 1) applet project that outputs jar file 2) web app
In my project, there are two view controllers - let's say firstViewController and secondViewController.
In virtually every project I've ever worked on, there will be one or two

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.