none
How to close the password window? RRS feed

  • Question

  • I entered login and password, MainWindow showed, but I need login and password window close. How this to write?

    var successValue = ops.DoWork(loginTextBox.Text, passwordTextBox.Text);
                        var workResult = string.IsNullOrWhiteSpace(successValue);
                        if (workResult)
                        {
                      MessageBox.Show("Operation is successful");
                                                   
                           Form MW = new MainWindow();
                            MW.Show();
    
                        }


    Friday, November 15, 2019 1:42 PM

Answers

  •                                this.Hide();                     
                           Form MW = new MainWindow();
                            MW.Closed+= (s, args) => this.Close();
                            MW.Show();
    • Marked as answer by Decompressor Friday, November 15, 2019 2:38 PM
    Friday, November 15, 2019 2:38 PM
  •                                this.Hide();                     
                           Form MW = new MainWindow();
                            MW.Closed+= (s, args) => this.Close();
                            MW.Show();

    FYI this is in my code sample.

    Hide();
    var mainForm = new MainForm(userNameBytes, passwordBytes);
    mainForm.ShowDialog();
    

    Where if no encryption would be 

    Hide();
    var mainForm = new MainForm(userName, password);
    mainForm.ShowDialog();

    Also, you don't need this prefixing Hide()


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    • Marked as answer by Decompressor Sunday, November 17, 2019 5:52 PM
    Friday, November 15, 2019 2:57 PM
    Moderator

All replies

  •                                this.Hide();                     
                           Form MW = new MainWindow();
                            MW.Closed+= (s, args) => this.Close();
                            MW.Show();
    • Marked as answer by Decompressor Friday, November 15, 2019 2:38 PM
    Friday, November 15, 2019 2:38 PM
  •                                this.Hide();                     
                           Form MW = new MainWindow();
                            MW.Closed+= (s, args) => this.Close();
                            MW.Show();

    FYI this is in my code sample.

    Hide();
    var mainForm = new MainForm(userNameBytes, passwordBytes);
    mainForm.ShowDialog();
    

    Where if no encryption would be 

    Hide();
    var mainForm = new MainForm(userName, password);
    mainForm.ShowDialog();

    Also, you don't need this prefixing Hide()


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    • Marked as answer by Decompressor Sunday, November 17, 2019 5:52 PM
    Friday, November 15, 2019 2:57 PM
    Moderator