private void Form1_Load(object sender, EventArgs e) { my_TextBoxApText = new A_文本框添加内容(TextAppText); my_ComboBoxAdd = new A_组合框添加表项(ComboBoxAddItem); //获取IP ArrayList mac = new ArrayList(); ArrayList ip = new ArrayList(); GetLocalIPAddress(ref mac, ref ip); for (int i = 0; i < ip.Count; i++) { IPAddress l = (IPAddress)ip[i]; DialogResult TS = MessageBox.Show("是否是这个IP在上网?(" + l.ToString() + ")", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (TS == DialogResult.Yes) { string ip1 = l.ToString(); this.Text = string.Format("本机IP:{0} MAC地址:{1}", ip1, mac[0]); textBox1.AppendText(this.Text + "\r\n"); string[] fg = ip1.Split(".".ToCharArray()); qm = string.Format("{0}.{1}.{2}.", fg[0], fg[1], fg[2]); break; } } if (qm == "") { this.Close(); } /* * this.Text = string.Format("本机IP:{0} MAC地址:{1}", ip, mac); * textBox1.AppendText(this.Text+"\r\n"); * string[] fg = ip.Split(".".ToCharArray()); * if (fg.Length != 4) { MessageBox.Show("获取的IP是错误的!"); } * qm = string.Format("{0}.{1}.{2}.",fg[0],fg[1],fg[2]); */ Thread t = new Thread(bl); t.IsBackground = true; t.Start(); }
public Form1() { InitializeComponent(); my_TextBoxApText = new A_文本框添加内容(TextAppText); my_ComboBoxAdd = new A_组合框添加表项(ComboBoxAddItem); }