hi
i develop one windows application in that application i am using 2 forms. i need first form textbox value to second form.
in web applications we use sessions. in place of sessions which can be used in windows applications?
please give a some idea or give a one sample solution
Thanks
Loading
C# CornerPosted Oct 8, 2010, 8:24 AM
u have to type in this way:
1- use public keyword if you wana to use form properties in all assemblies (all projects)
2- use internal if wana to use properties from same assembly (same project)
thanks
Bye
Omid Eidivandi
MCPD
Gomathi PalaniswamyPosted Oct 8, 2010, 7:21 AM
you can achieve like this,
declare a public variable like
public str=textbox1.text;
create the instance of the form like
Form1 frm=new Form1();
string str=frm.str;
Jean PaulPosted Oct 8, 2010, 5:58 AM
There are multiple ways of achieving it. I will suggest the easiest one :)
1) In the form1, selecte the textbox and in properties window change the Modifiers property to Public.
This will make the modifier of TextBox in form1 to be public like following
public System.Windows.Forms.TextBox textBox1;
Now the textbox could be accessible from the form 2 as following:
Form1 form1 = new Form1();
string value =form1.textBox1.Text;
Hope this could answer your question.
Cheers,
JP