Click here to Skip to main content
15,907,281 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hello

I have login form with dynamic login

C#
private void button1_Click(object sender, EventArgs e)
        {
            dynamic login = this.usersTableAdapter1.userpasswordString(txtKorisnik.Text, txtLozinka.Text);
            if (login == null)
            {
                MessageBox.Show("Login fail!");
            }
            else
            {
                start str = new start();
                str.Show();
                this.Hide();


where userpasswordString is query from dataset and it works fine, but I want to be able that upon succesfull login in main form called start as it seen in code to see the name of logged in user in textbox, just dont know how to do it??????

Help?
Posted
Updated 8-May-11 22:47pm
v2

in the Start form use a label box.When user succesfully logs in enable it and show the user name in the label box.

///START FORM
label1.enabled=true;
label1.text=txtKorsinik.text;



hope this helps you.
 
Share this answer
 
v2
You can add the textbox in strat form whose modifir is public...

so the code can be..

Start str = new Start();
     str.txt_usr.Text = usr.Text;
     str.Show(); 


I think this might help you.
 
Share this answer
 
Comments
shonezi 9-May-11 6:42am    
it doesnt work
Hi shonezi,

In the start form you can edit its constructor by adding a new parameter like this :

public start (string User_Name)
{
    InitializeComponent();

    textBox1.Text = User_Name;   // where textBox1 is the textbox you want to fill with the UserName
}


and in your login code you can call start as follows :

start str = new start(textBox1.text);  // where textBox1 is the textBox where the username is entered
str.Show();


Here your you can access the username from start form from anywhere in the start form class.

I hope this helps you,
:)
 
Share this answer
 
v2
Comments
shonezi 9-May-11 5:48am    
Hello, thanks for the answer, but I have a problem, login form runs on application run so only when I type in correct username and password does the start form opens up, and on this start form I have textbox where I want to see logged in user. I did what u told me but nothing happened, I still don't see the username in textbox????
Michael Waguih 9-May-11 6:03am    
I have edit the code try it now.
shonezi 9-May-11 6:04am    
it says I cant put argument as textbox1.Text in login code.
Michael Waguih 9-May-11 6:42am    
textbox1 is only an example ... put your username string.
Ihave written this before !!!
shonezi 9-May-11 7:27am    
I did put it already mz username string inside it, I just refered to textbox as example also :)))

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