Click here to Skip to main content
14,732,921 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm deveoping a window application ,having two forms. first form is calculating some values and diplaying in 4 text boxes,now i want to add these values to datagrid on other form.
Updated 21-Jul-10 2:59am
OriginalGriff 21-Jul-10 8:21am
What part of this is giving you problems?

you can set the "Modifier" property on the text boxes to "Public" that would make them available for the other form2 so you could say like this on the form1

Form1 frm = new Form1();
DataTable dtb=new DataTable();


DataGridView drg=new DataGridView();
If the source of the data grid is a table, you might want to add data to the table and simply show the grid.
It is not entirely clear what you want to achieve.
Forms in C# are instances of classes themselves. So you could make 4 variables public and set their values before you close the form or switch back to the other form.

class form2
public string txtbox1;
public string txtbox2;
public string txtbox3;
public string txtbox4;

Wherever you call this form from.

form2 f2 = new form2();

if (f2.ShowDialog() == DialogResult.OK)
   //to get variables 
   f2.txtbox1; //etc... to retrive values

If this is unclear please let me know I will try to explain further.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900