Automatically Populate form from text box value when it opens

Aug 18 2008 2:05 PM
Here is a newbie question for you.

I have a main form that opens a second form like this

private void button2_Click(object sender, EventArgs e)
{
Form3 form3 = new Form3();
form3.employeenumberToolStripTextBox.Text = employeeNumberTextBox.Text;
form3.Show();
form3.Owner = this;
}

When form3 opens, I have to click the enter button again (has the information from form1 textbox) to populate the form. How can I automatically have the click event activated when the form opens instead of having to click the enter button?
Does this make sense?

My form3 looks like this:

 public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void sp_CLE_SelectRowBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.sp_CLE_SelectRowBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.employee_DataDataSet);

        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                this.sp_CLE_SelectRowTableAdapter.Fill(this.employee_DataDataSet.sp_CLE_SelectRow, new System.Nullable<int>(((int)(System.Convert.ChangeType(employeenumberToolStripTextBox.Text, typeof(int))))));
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }
    }
}


Answers (4)