private void btn_Edit_Click(object sender, EventArgs e) { int currentRowIndex; //Get the currently selected row for later recall if (dgv_Accounts.SelectedRows.Count > 0) { currentRowIndex = dgv_Accounts.SelectedRows[0].Index; } else { return; } //Instantiate a new "Edit_Account" object and pass in the variables and parent form Edit_Account edit_account = new Edit_Account(this); edit_account.dtRow = currentRowIndex; edit_account.acctName = this.dt.Rows[currentRowIndex][0].ToString(); edit_account.email = this.dt.Rows[currentRowIndex][1].ToString(); edit_account.password = this.dt.Rows[currentRowIndex][2].ToString(); edit_account.server = this.dt.Rows[currentRowIndex][3].ToString(); edit_account.prodKey = this.dt.Rows[currentRowIndex][4].ToString(); edit_account.apiKey = null; edit_account.ShowDialog(); }