Click here to Skip to main content
15,353,748 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I am doing windows application project in this i have login form

in login form i have controls like username = txtusername ; password = txtpassword

this two controls i will pass i will get user id here this user id i want to save some anther form how to do?
Posted
Updated 23-May-12 22:14pm
v6
Comments
MAKReddy 24-May-12 2:23am
   
In Another form i created for object for login form but its not coming
i tried obj.controlname but control is not showing
AhsanS 24-May-12 2:52am
   
Do you want to get some information from another form?
MAKReddy 24-May-12 2:41am
   
i am doing windows app. i think here no master page
MAKReddy 24-May-12 3:00am
   
@Ahsans
yes i want some information from another form
Mohamed Mitwalli 24-May-12 9:29am
   
Why you undo the Answer ??

If you pass values to another Form means first created global variables and stored that values and then pass values to another form , below Sample code try this one
C#
 public global{
public static String gblLoginID ;
public static String  gblPassword ;
}

public class Form1{
global .gblLoginID=textbox1.text;
}
public class Form2{
textbox2.text=global .gblLoginID;
}
   
v2
Hi ,
You can also use Constructor

C#
//Form1
private void button1_Click(object sender, EventArgs e)
{
    Form2 frm = new Form2(txtUser.Text , txtPass.Text);
    frm.Show();
}
//Form2
  string username1, password1;
        public Form2(string username  , string password)
        {
            InitializeComponent();
            username1 = username ;
            password1 = password ;
        }
        private void Form2_Load(object sender, EventArgs e)
        {
            MessageBox.Show(username1+"  "+password1);
        }

Best Regards
M.Mitwalli
   
You should expose properties of that form and access the properties from the calling form
e.g.
you want some information from form 2
you should expose properties like
C#
public String LoginID {get;set;}
public String  Password {get;set;}


in form 2 set these 2 properties and from login form
you can access these properties via instance of form2.

i.e form2.LoginID
form2.Password
   

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