ITPub博客

首页 > > > winform 神奇的问题高手进

winform 神奇的问题高手进

作者:dapan 时间:2019-11-07 13:45:26 0 删除 编辑

1.Form2 打开后马上就关闭了???为什么??    

public partial class Form1 : Form    

{        

        public Form1()       

       {            

            InitializeComponent();        

       }

        private Thread tr;

        private void button1_Click(object sender, EventArgs e)        

        {           

          tr = new Thread(new ThreadStart(Do));           

          tr.IsBackground = true;           

          tr.Start();        

       }

        private void Do()        

        {            

           Form2 f = new Form2();

           f.Show();        

         }   

       }

2.MessageBox 不能到最前面来。。被Form2窗体挡住了...??为什么呀??    

public   partial class Form1 : Form    

{        

     public Form1()        

         {            

             InitializeComponent();        

         }

        private Thread tr;        

        private void button1_Click(object sender, EventArgs e)        

        {           

            tr = new Thread(new ThreadStart(Do));           

            tr.IsBackground = true;           

             tr.Start();

           Thread.Sleep(2000);           

            MessageBox.Show("晕!!!");        

         }

        private void Do()        

        {            

           Form2 f = new Form2(); f.ShowDialog();        

        }    

}

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/758/viewspace-3166994/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2020-08-07

  • 博文量
    4504
  • 访问量
    87093