private void CMDCancel_Click(object sender, EventArgs e) { Device_manager lForm1 = (Device_manager)this.Owner; //把Form2的父窗口指針賦給lForm1 lForm1.GetAddDeviceName = null; //使用父窗口指針賦值 Close(); }
private void CMDApply_Click(object sender, EventArgs e) { if (nodeName.Text != "") { ListBox add = new ListBox(); add.Items.Add(nodeName.Text); Device_manager lForm1 = (Device_manager)this.Owner; //把Form2的父窗口指針賦給lForm1 lForm1.GetAddDeviceName = add; //使用父窗口指針賦值 this.Close(); } }
private void CMDApply_Click(object sender, EventArgs e) { string returnValue = "", returnStr = ""; string returnIP = ""; ListBox returnObj = new ListBox(); if (potocolType.SelectedIndex == 1) { if (nicoip.Text != "") { returnIP = nicoip.Text; returnValue = comboBox1.Text; returnStr = "nico%" + returnIP + "%" + returnValue; returnObj.Items.Add(returnStr); Device_manager lForm1 = (Device_manager)this.Owner;//把Form2的父窗口指針賦給lForm1 //lForm1.GetAddDeviceName = "nico%" + returnIP + "%" + returnValue; //使用父窗口指針賦值 lForm1.GetAddDeviceName = returnObj; if (useInput.Checked == true) { lForm1.reip = Lonip.Text; } else if (useTemp.Checked == true) { lForm1.reip = comboBox2.Text; } this.Close(); } else { MessageBox.Show("ip address empty!"); } } else if (potocolType.SelectedIndex == 0) { if (LonDeviceList.SelectedItem != null || tempList.SelectedItem != null) { if (Lonip.Text != "") { if (useInput.Checked == true) { for (int itemcount = 0; itemcount < LonDeviceList.Items.Count; itemcount++) { if (LonDeviceList.GetSelected(itemcount) == true) { returnIP = Lonip.Text; returnValue = LonDeviceListPath.Items[itemcount].ToString(); returnStr = "lon%" + returnIP + "%" + returnValue; returnObj.Items.Add(returnStr); } } } else if (useTemp.Checked == true) { for (int itemcount = 0; itemcount < tempList.Items.Count; itemcount++) { if (tempList.GetSelected(itemcount) == true) { returnIP = comboBox2.Text; returnValue = tempListpath.Items[itemcount].ToString(); returnStr = "lon%" + returnIP + "%" + returnValue; returnObj.Items.Add(returnStr); } } } Device_manager lForm1 = (Device_manager)this.Owner;//把Form2的父窗口指針賦給lForm1 //lForm1.GetAddDeviceName = "lon%" + returnIP + "%" + returnValue; //使用父窗口指針賦值 lForm1.GetAddDeviceName = returnObj; this.Close(); } else { MessageBox.Show("ip address empty!"); } } else { MessageBox.Show("device empty!"); } } }