private void btnFormatData_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in dgvTransmission.SelectedRows) { TElement_Constant selectedTE = row.DataBoundItem as TElement_Constant; //gets the selected element if (selectedTE != null) //not sure if this is necessary { using (var form = new CharEntry(selectedTE)) { form.ShowDialog(); this.UpdateTransDGV(); } } } }