private void menuedit_Click(object sender, EventArgs e) { try { if (dg.SelectedRows.Count > 0) { FrmRemote f = new FrmRemote(); f.txtip.Text = dg.SelectedRows[0].Cells[0].Value.ToString(); f.txttitle.Text = dg.SelectedRows[0].Cells[1].Value.ToString(); f.txtuser.Text = dg.SelectedRows[0].Cells[2].Value.ToString(); f.txtpass.Text = dg.SelectedRows[0].Cells[0].Tag.ToString(); f.txtdescription.Text = dg.SelectedRows[0].Cells[1].Tag.ToString(); f.rfile = dg.SelectedRows[0].Tag.ToString(); if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK) { dg.SelectedRows[0].Cells[0].Value = f.txtip.Text; dg.SelectedRows[0].Cells[1].Value = f.txttitle.Text; dg.SelectedRows[0].Cells[2].Value = f.txtuser.Text; dg.SelectedRows[0].Cells[0].Tag = f.txtpass.Text; dg.SelectedRows[0].Cells[1].Tag = f.txtdescription.Text; } f.Dispose(); } else { MessageBox.Show("Please select any remote computer.", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (System.Exception ex) { AppUtils.Error(ex.ToString()); } }
private void lbladd_Click(object sender, EventArgs e) { FrmRemote f = new FrmRemote(); if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string[] tmp2 = { f.txtip.Text, f.txttitle.Text, f.txtuser.Text }; dg.Rows.Add(tmp2); dg.Rows[dg.Rows.Count - 1].Tag = f.rfile; dg.Rows[dg.Rows.Count - 1].Cells[0].Tag = f.txtpass.Text; dg.Rows[dg.Rows.Count - 1].Cells[1].Tag = f.txtdescription.Text; RemoteMachine.list.Add(new RemoteMachine(f.txtip.Text, f.txttitle.Text, f.txtuser.Text, f.txtpass.Text, f.txtdescription.Text, f.rfile)); } f.Dispose(); }