Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to pass textbox value from form1 to another form2 by using static.
Can U give me an example. PLZ HELP ME...
Posted

That is very vague. Form1 and Form2 are instances of a particular class and therefore passing it to a static variable would mean that every instance of the class could use it. But if that's the case you simply declare a static variable and assign it to the class and not the class instance.
C#
class Form2
{
   public static string value;
}

...
Form2.value = Form1Object.SomeTextbox.Value;


Good luck!
 
Share this answer
 
You need to add your static fields to the App class. That class persist through page navigation. You page forms would need to read and write to fields exposed on your App instance. Since only one form exists at a time you wouldn't be able to directly pass information without this intermediary.
 
Share this answer
 

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