private void TsAddToLis_Click(object sender, EventArgs e) { if (dgMembers.SelectedRows.Count > 0) { DataGridViewRow row = dgMembers.SelectedRows[0]; LanMachine machine = row.Tag as LanMachine; if (machine == null) { return; } string nickName = FrmInputBox.ShowInputBox("请输入机器昵称"); if (string.IsNullOrWhiteSpace(nickName)) { return; } machine.NickName = nickName.Trim(); DataGridViewRow newrow = GetRow(machine, gvLis); RefreashWeb(); try { SaveLisTo(LastListenFile); } catch { } } }
private void TsEditLis_Click(object sender, EventArgs e) { if (gvLis.SelectedRows.Count > 0) { DataGridViewRow row = gvLis.SelectedRows[0]; LanMachine machine = row.Tag as LanMachine; if (machine == null) { return; } string nickName = FrmInputBox.ShowInputBox("请输入机器昵称"); if (string.IsNullOrWhiteSpace(nickName)) { return; } machine.NickName = nickName.Trim(); SetCellValue("ColLisName", machine.NickName, row); RefreashWeb(); try { SaveLisTo(LastListenFile); } catch { } } }
/// <summary> /// 显示输入框 /// </summary> /// <param name="title"></param> /// <returns></returns> public static string ShowInputBox(string title) { using (FrmInputBox frm = new FrmInputBox()) { frm.Text = title; frm.StartPosition = FormStartPosition.CenterParent; if (frm.ShowDialog() == DialogResult.OK) { return(frm.txtContent.Text); } } return(null); }