private void btnTambahAndReturnObject_Click(object sender, EventArgs e) { var form = new FrmTambahData(); var returnValue = form.RunAndReturnObjectMahasiswa(form); if (returnValue != null) { this.dgvData.Rows.Add(new string[] { returnValue.Nim, returnValue.Nama }); } }
private void dgvData_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (this.dgvData.CurrentRow != null) { var row = this.dgvData.CurrentRow; string nim = row.Cells[0].Value.ToString().Trim(); string nama = row.Cells[1].Value.ToString().Trim(); //FrmTambahData form = new FrmTambahData(nim, nama); FrmTambahData form = new FrmTambahData(new Mahasiswa { Nim = nim, Nama = nama }); var returnValue = form.RunAndReturnObjectMahasiswa(form); if (returnValue != null) { row.Cells[0].Value = returnValue.Nim; row.Cells[1].Value = returnValue.Nama; } } }