| I am new to c#. I have the following in my project in windows forms: Form1 with button and DataGridView. Form2 with button. Form3 with button and 3 textBoxes. In form1, I click buttonOpenForm2 form2 pops up. Then in form2 I click buttonOpenForm3 form3 pops up which has 3 text boxes and button. Now the 3 forms are open. now in form3, I enter values in textBox1, textBox2 and textBox3 and when click buttonAddRow ( from form3) I want these values to be inserted into the DataGRidView in Form1. My question is: How can I add a row into DataGridView in Form1 ( parent) from form3 (child of child form) WITHOUT closing form2 and form3? I mean I want to pass the data while form2 and form3 are still open. Please help me. Thank you Form1: public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void buttonOpenForm2 _Click(object sender, EventArgs e) { Form2 frm2 = new Form2(); frm2.Show(); } } Form2: public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void buttonOpenForm3 _Click(object sender, EventArgs e) { Form3 frm3 = new Form3(); frm3.Show(); } } Form3: public partial class Form3 : Form { public Form3() { InitializeComponent(); } private void buttonAddRow _Click(object sender, EventArgs e) { //What to write here to insert the 3 textboxes values into DataGridView? } } |
Loading
Siva SankarPosted Nov 29, 2015, 11:33 PM
Raja TPosted Nov 29, 2015, 10:58 PM
{public Form3(){{ //What to write here to insert the 3 textboxes values into DataGridView?Globalvariable. SomeData1 = textBox1.Text;frm1.Show();Siva SankarPosted Nov 28, 2015, 12:09 AM
naouf gydPosted Nov 27, 2015, 2:45 PM
naouf gydPosted Nov 27, 2015, 2:45 PM
naouf gydPosted Nov 27, 2015, 2:45 PM
naouf gydPosted Nov 27, 2015, 2:45 PM
Raja TPosted Nov 27, 2015, 12:01 AM
{public Form3(){{ //What to write here to insert the 3 textboxes values into DataGridView?Globalvariable. SomeData1 = textBox1.Text;{public Form1(){ InitializeComponent();dr = dt.NewRow();{
dr["Name"] = Globalvariable. SomeData1 ;
dr["Address"] = Globalvariable. SomeData2;
dr["Age"] = Globalvariable. SomeData3;
dt.Rows.Add(dr);
dataGridView1.DataSource = dt;
clear();
}
}