Form1: Parent form,
Form2: Child form.
1. The parent form receives the return value of the subform:
Public Partial class Form1:form { privatevoid Btnopen_click (object sender, EventArgs e) { New Frmcorpdtadd (dsservice); if (FD. ShowDialog () = = DialogResult.Cancel) // Open Subform, and after closing { = fd._ Retrowguid; // receive the value of the subform here } } }
Public Partial classForm2:form { Public string_retrowguid;//define common global variables for easy access to other forms, record values returned to the parent form Private voidBtnsave_click (Objectsender, EventArgs e) {_retrowguid= dgsg_aptitudeproject.currentrow.cells["RowGuid"]. Value.tostring ();//DataGridView The Rowguid value of the selected row to the global variable _retrowguid This. DialogResult = DialogResult.Cancel;//Cancel (Close) } }
Post-processing modification ...
Passing values between C # forms