Parent Form1 Child Form2 Form1 has a datagridview control and an add button.
There is a Text control and a save button in Form2. You need to click the Add button on Form1 form to pop up Form2.
Enter the content in text, click Save to automatically close Form2, refresh the data in the datagridview in Form1
From1:
private void button3_Click(object sender, EventArgs e) { Form2 f2 = new Form2(); (); if ( == ) { ();//Rebind } }
From2:
<BR><BR>private void button1_Click(object sender, EventArgs e) { string strConn = "server=.;database=filesSync;uid=sa;pwd=123"; SqlConnection conn = new SqlConnection(strConn); string sql = "insert into asyncFileList values ('" + () + "')"; (); SqlCommand myCmd = new SqlCommand(sql, conn); (); (); = ; ("Added successfully"); (); }
The above example of closing and refreshing the parent form in winform C# is the entire content I share with you. I hope you can give you a reference and I hope you can support me more.