private void button_newHost_Click(object sender, System.EventArgs e) { HostNameDlg dlg = new HostNameDlg(); dlg.Font = this.Font; dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(this); if (dlg.DialogResult == DialogResult.OK) { ListViewItem item = new ListViewItem(dlg.textBox_hostAddress.Text, 0); listView_hosts.Items.Add(item); bChanged = true; } }
private void button_ModiHost_Click(object sender, System.EventArgs e) { if (listView_hosts.SelectedItems.Count == 0) { MessageBox.Show(this, "请先选择要修改的host事项"); return; } HostNameDlg dlg = new HostNameDlg(); dlg.Font = this.Font; dlg.textBox_hostAddress.Text = listView_hosts.SelectedItems[0].Text; dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(this); if (dlg.DialogResult == DialogResult.OK) { listView_hosts.SelectedItems[0].Text = dlg.textBox_hostAddress.Text; bChanged = true; } }