private void BadBackgroundLaunch(object state)
    {
        var form2 = new SecondForm();

        form2.Text = "Bad one";
        form2.Show();
    }
    private void dataGridView_CellClick(object sender, EventArgs e)
    {
        //This event fires every time user click cell
        if (sf == null)
        {
            //This means our second form has not been initialized so maybe show message to user and return or open it up
            //First solution
            sf = new SecondForm();
            sf.Show();
            //Second solution
            MessageBox.Show("Second form is not initialized!");
            return;
        }
        //I would here check if(sf.Visible) and if it is not i would sf.Show();
        //We check if same row has been selected. If it does then we do nothing
        if (dataGridView.SelectedRows[0].Index == lastSelectedRow)
        {
            return;
        }
        int    uid   = Convert.ToInt32(row.Cells["ColumnThatContainsUserId"].Value);
        string uname = row.Cells["ColumnThatContainsUserName"].Value.ToString();

        sf.SwitchUser(uid, uname);    //Accessing through global variable
        lastSelectedRow = dataGridView.SelectedRows[0].Index;
    }
 static void Go()
 {
     f1 = new FirstForm();
     f2 = new SecondForm();
     f1.DateSelected += new EventHandler <DateEventArgs>(f1_DateSelected);
     f1.Show();
     f2.Show();
 }
Exemple #4
0
 static void Go()
 {
     f1 = new FirstForm();
     f2 = new SecondForm();
     f1.DateSelected += (o, e) => f2.SelectedDate = e.Date.AddMonths(6);
     f1.Show();
     f2.Show();
 }
 private void GoodBackgroundLaunch(object state)
 {
     this.Invoke((Action)(() =>
     {
         var form2 = new SecondForm();
         form2.Text = "Good One";
         form2.Show();
     }));
 }
 public void OpenSecondForm()
 {
     // create it only once
     if (_secondForm == null)
     {
         _secondForm = new SecondForm();
     }
     // otherwise just show it
     _secondForm.Show();
 }
    private void button1_Click(object sender, EventArgs e)
    {
        var person = new Person();

        person.Name = txtName.Text;
        if (int.TryParse(txtAge.Text, out int age))
        {
            person.Age = age;
        }
        var form2 = new SecondForm(person);

        form2.Show();
    }
Exemple #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            SecondForm form = new SecondForm(textBox1.Text);

            form.UserName = textBox1.Text;
            if (DialogResult.OK == form.ShowDialog())
            {
            }                                             //ShowDialog invokes the modal form
            textBox1.Text = form.UserName;
            if (form != null)
            {
                form.Close();
            }
            form          = new SecondForm();
            form.UserName = textBox1.Text;
            form.Visible  = true;
            form.Show(this);
        }
Exemple #9
0
    private void button1_Click(object sender, EventArgs e)
    {
        SecondForm form2 = new SecondForm(this);

        SecondForm.Show();
    }
    private void OnUpdateLastButton_Clicked(object sender, EventArgs e)
    {
        var childForm = new SecondForm();

        childForm.Show();    //Shows the second form
    }