0

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();
        }
2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by MrBlack
Featured Replies
  • 1
    __avd 1,826   6 Years Ago

    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] Read More

  • [QUOTE=adatapost;1260669]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][/QUOTE] Thanks a lot [B]adatapost[/B] Read More

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.