Main form Form1 Key code:
Eject the most dialog box mode of the subform and update the main form when the form is closed or canceled
Copy Code code as follows:
private void Simplebutton1_click (object sender, EventArgs e)
{
Form2 F2 = new Form2 ();
F2. Owner = this;
DialogResult Result=f2. ShowDialog ();
if (result = = DialogResult.Cancel)
{
This.gridControl1.DataSource = F2. CreateTable ();
}
}
Child form
Copy Code code as follows:
private void Simplebutton1_click (object sender, EventArgs e)
{
Thi S.close ();
}
Public DataTable createtable ()
{
DataTable tableA1 = new DataTable ();
TableA1.Columns.AddRange (New datacolumn[] {new DataColumn ("name"), New DataColumn ("Spec"), New DataColumn ("number"), new DataColumn ("Quantity")});
TableA1.Rows.Add (new object[] {"Helix", "Ls-x", "111", "2"});
TableA1.Rows.Add (new object[] {"Helix", "ls-x", "222", "1"});
TableA1.Rows.Add (new object[] {"Pointer", "LX-3", "523", "2"});
TableA1.Rows.Add (new object[] {"Other", "L-1", "666", "2"});
TableA1.Rows.Add (new object[] {"Other", "L-1", "456", "1"});
TableA1.Rows.Add (new object[] {"Other", "L-1", "990", "2"});
return tableA1;
}