1.控制台添加弹出窗体
1.1 右键项目名称–》添加–》windows窗体
1.2 添加
1.3 Program.cs程序设计
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 弹出窗体设计
{
class Program
{
static void Main(string[] args)
{
Form1 form1 = new Form1();
Console.WriteLine("请输入弹出内容:");
form1.str = Console.ReadLine();
form1.ShowDialog();
/*
Form2 form2 = new Form2();
Console.WriteLine("请输入弹出内容:");
form2.str = Console.ReadLine();
form2.ShowDialog();
*/
}
}
}
1.4 Form1窗体设计
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 弹出窗体设计
{
public partial class Form1 : Form
{
public string str;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
textBox1.Text = str;
}
}
}
1.5 Form2窗体设计
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 弹出窗体设计
{
public partial class Form2 : Form
{
public string str;
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
textBox1.Text = str;
}
}
}
2.运行结果