C#实现窗体弹出的三种方式
以下是C#实现窗体弹出的三种方式的完整源码:
- 使用Show方法弹出窗体:
using System;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2();
form2.Show();
}
}
}
- 使用ShowDialog方法弹出模态窗体:
using System;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2();
form2.ShowDialog();
标签:C#,System,Form2,Form1,源码,窗体,using,public
From: https://blog.csdn.net/it_xiangqiang/article/details/137180434