Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (richTextBox1.Text != "")
- {
- mainForm newMainForm = new mainForm();
- newMainForm.dataGridView1.ColumnCount = 3;
- newMainForm.dataGridView1.Columns[0].Name = "Product ID";
- newMainForm.dataGridView1.Columns[1].Name = "Product Name";
- newMainForm.dataGridView1.Columns[2].Name = "Product Price";
- string[] row = new string[] { "1", "Product 1", "1000" };
- newMainForm.dataGridView1.Rows.Add(row);
- row = new string[] { "2", "Product 2", "2000" };
- newMainForm.dataGridView1.Rows.Add(row);
- row = new string[] { "3", "Product 3", "3000" };
- newMainForm.dataGridView1.Rows.Add(row);
- row = new string[] { "4", "Product 4", "4000" };
- newMainForm.dataGridView1.Rows.Add(row);
- }
- subForm sub = new SubForm();
- sub.Show(); // or however you have done it
- private mainForm _parent;
- internal void RegisterParent(mainForm form)
- {
- // error handling of course, make sure form is not null, or you don't already have a parent
- this._parent = form;
- }
- sub.RegisterParent(this);
- if (richTextBox1.Text != "")
- {
- _parent.dataGridView1.ColumnCount = 3;
- _parent.dataGridView1.Columns[0].Name = "Product ID";
- _parent.dataGridView1.Columns[1].Name = "Product Name";
- _parent.dataGridView1.Columns[2].Name = "Product Price";
- string[] row = new string[] { "1", "Product 1", "1000" };
- _parent.dataGridView1.Rows.Add(row);
- row = new string[] { "2", "Product 2", "2000" };
- _parent.dataGridView1.Rows.Add(row);
- row = new string[] { "3", "Product 3", "3000" };
- _parent.dataGridView1.Rows.Add(row);
- row = new string[] { "4", "Product 4", "4000" };
- _parent.dataGridView1.Rows.Add(row);
- }
Add Comment
Please, Sign In to add comment