Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
C#



C#
private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F3)
            {

                Form2 f2 = new Form2();
                f2.ShowDialog();
                textBox1.Text = f2._username;


            }
        }
Posted
Updated 7-Nov-11 16:54pm
v2
Comments
Prerak Patel 7-Nov-11 22:54pm    
What is the problem?
Sam Path 7-Nov-11 22:55pm    
I want to pass the parameter(username) for this code.

1 solution

A "parameter" is an attribute of specific programming entities, such as method, SQL query, etc. This is code, making not so much sense, just needs a valid username to assign to the text box text property. You can simply make f2.Username an internal property, reading the value of private _username in its getter.

In a more general view, this is the popular question about form collaboration. The most robust solution is implementation of an appropriate interface in form class. Please see my past solution for more detail: How to copy all the items between listboxes in two forms[^].

—SA
 
Share this answer
 
v2

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