Jump to content

windows forms not hiding properly??

- - - - -

  • Please log in to reply
3 replies to this topic

#1
cacheBandit

cacheBandit

    Newbie

  • Members
  • Pip
  • 8 posts
ok so here is the deal, i have a windows form application, and in this application right now what i simply want to do is have the program to open up the loginScreen form and when i click the log in button i want it to hide the loginScreen and show the mailer form. so first what i did in the program code under static main i have:
        static void Main()

        {

            Application.EnableVisualStyles();

            Application.SetCompatibleTextRenderingDefault(false);

            Application.Run(new loginScreen());

        }
then my code for when the login button is clicked is
        private void logIn_Click(object sender, EventArgs e)

        {

            loginScreen loginscreen = new loginScreen();

            loginscreen.Hide();


            mailer mailer = new mailer();

            mailer.Show();  

        }
when i click the log in button the mailer opens up like i would want however the loginScreen just moves behind the mailer form and is just chillin there.. and i have tried many variations of this concept and still no luck.. am i just using the wrong code?

anyone who can shed a light on this is my hero! thanks :D

#2
PsychoCoder

PsychoCoder

    Learning Programmer

  • Members
  • PipPipPip
  • 92 posts
Well you're creating a new instance of loginScreen when you click the button, so instead of this

private void logIn_Click(object sender, EventArgs e)
        {
            loginScreen loginscreen = new loginScreen();
            loginscreen.Hide();

            mailer mailer = new mailer();
            mailer.Show();  
        }

Try this

private void logIn_Click(object sender, EventArgs e)
        {
            mailer mailer = new mailer();
            mailer.Show();  
            this.Hide();
        }


#3
cacheBandit

cacheBandit

    Newbie

  • Members
  • Pip
  • 8 posts
aww soo simple, i figured it had something to do with the the fact that i was creating a new instance of it, i just didnt know how else to do it. now i know thanks soo much! you are my hero :P

#4
cacheBandit

cacheBandit

    Newbie

  • Members
  • Pip
  • 8 posts
what would i use to transfer a variable that is initiated on the login screen to the mailer form so i can use it on the mailer form? or should i initiate it in the static void main method?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users