using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading; using System.Windows.Forms; namespace Nanji_Island { public partial class Form2 : Form { //本机Ip public static String LocalIp; //端口号 public static String port; public Form2() { InitializeComponent(); //使最大化窗口失效 this.MaximizeBox = false; //禁用对窗口大小进行拖拽 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; //调用tool工具类 获取本机Ip LocalIp = tool.GetLocalIP(); //将本机Ip显示在界面上 ipaddress.AppendText("192.168.1.100"); //设置默认端口号 _port.AppendText("8899"); } private void button1_Click(object sender, EventArgs e) { //获取端口文本框内的ip及端口号并赋值 LocalIp = ipaddress.Text; port = _port.Text; //打开第二个界面并关闭当前界面 Thread th = new Thread(delegate () { new Form1().ShowDialog(); }); th.Start(); this.Close(); } private void Form2_Load(object sender, EventArgs e) { } } }