form.show和form.Activate之间的区别 [英] Difference between form.show and form.Activate

查看:329
本文介绍了form.show和form.Activate之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道 form.show() form.activate()之间的区别。

I would like to know the difference between form.show() and form.activate().

我已经打开了多个表单,我想激活另一个表单后面的表单,这是调用所需表单
form.show() form.activate()

I have multiple forms that already opened and i would like to active my form that is behind another form which is the best way to call my desired form form.show() or form.activate()?

推荐答案

方法 Show()将表单显示给用户。

The method Show() displays the form to the user.

方法 Activate()将表单置于最前面(它使表单焦点突出)。

The method Activate() brings the form to the front (it gives the form focus).

示例:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        Form2 form2 = new Form2();
        form2.Show();
        this.Activate();
    }
}

上面的代码将通过调用<$ c来显示form2 $ c> form2.Show(); ,但是由于 this.Activate(); ,form1将位于form2前面(焦点对准)

The above code will show form2 by calling form2.Show(); but form1 will be in front of form2 (in focus) because of the this.Activate(); call.

请参阅MSDN文档:

  • Show()
  • Activate()

这篇关于form.show和form.Activate之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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