i have created two winforms ,first from take a value and pass it into the second form and display on a label, but when i run the programme it throws exception

form 1

private void button1_Click(object sender, EventArgs e)
        {
              Form2 fm2 = new Form2(this.txtName.Text);
              fm2.Show();
        }

form 2

Form2 Constructor

public Form2(string parm)
        {
            this.label1.Text = parm;
            InitializeComponent();
        }

Recommended Answers

Read - [url]http://stackoverflow.com/questions/1042706/where-and-when-is-initializecomponent-called-in-windows-forms-control-in-vb-net[/url]

[code]
public Form2(string parm)
{
InitializeComponent();
this.label1.Text = parm;
}
[/code]

Jump to Post

All 2 Replies

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.