为什么我的表没有关闭/隐藏? [英] Why is my Form not Closing/Hiding?

查看:100
本文介绍了为什么我的表没有关闭/隐藏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白为什么我的登录表单不打烊或者即使我已经在使用this.Hide躲起来了,我试图从然后打开另外一个关闭,第二种形式是开放,但登录仍存在运行这是为什么? 这里是我的code

 公共无效verifyAccount()
        {
            变种hashedPassword = getPassword来();

            VAR散列器=新的散列器();

            hasher.SaltSize = 16;

             hasher.CompareStringToHash(txtPassword.Text,hashedPassword);

            如果(!hasher.CompareStringToHash(txtPassword.Text,hashedPassword))
            {
                的MessageBox.show(无效的用户名或密码);
            }
            其他
            {
                主窗口主=新的主窗口();

                main.ShowDialog();
                this.Hide();
            }
        }
 

编辑:随着人民发表评论,我发现了如何将我关在日志中形式的理念,这是我的解决方法

 主窗口主=新的主窗口();
                this.Hide();
                main.ShowDialog();
                this.Close();
 

解决方案

main.ShowDialog(); 是一个阻塞调用。控制不会运行到下一行,直到关闭主窗口。

I don't get it why my Log in form is not closing or hiding even though I am already using the "this.Hide, I am trying to close the from then opening another one, the second form is opening but the Log in is still there running why is that? here is my code

public void verifyAccount()
        {
            var hashedPassword = getPassword();

            var hasher = new Hasher();

            hasher.SaltSize = 16;

             hasher.CompareStringToHash(txtPassword.Text, hashedPassword);

            if (!hasher.CompareStringToHash(txtPassword.Text, hashedPassword))
            {
                MessageBox.Show("Invalid UserName or Password");
            }
            else
            {
                MainWindow main = new MainWindow();

                main.ShowDialog();
                this.Hide();
            }   
        }

EDIT: With the peoples comment I found an Idea of how will I close the log in form, here's my workaround

MainWindow main = new MainWindow();
                this.Hide();
                main.ShowDialog();
                this.Close();

解决方案

main.ShowDialog(); is a blocking call. Control will not run to the next line until you close the main window.

这篇关于为什么我的表没有关闭/隐藏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆