winForm 程序开发界面参数传递

时间:2023-11-24 11:23:32

1.

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace WindowsFormsApplication2
  11. {
  12. public partial class Form1 : Form
  13. {
  14. public Form1()
  15. {
  16. InitializeComponent();
  17. }
  18. private void ButtonClickMethod(object sender, EventArgs e)
  19. {
  20. this.nextForm = new Form2(this);
  21. this.nextForm.Show();
  22. }
  23. private Form2 nextForm;
  24. private void checkBox1_Click(object sender, EventArgs e)
  25. {
  26. this.nextForm.Close();
  27. }
  28. }
  29. }

2.

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace WindowsFormsApplication2
  11. {
  12. public partial class Form2 : Form
  13. {
  14. public Form2(Form1 f)
  15. {
  16. this.prevForm = f;
  17. InitializeComponent();
  18. }
  19. private Form1 prevForm;
  20. private void button1_Click(object sender, EventArgs e)
  21. {
  22. }
  23. }
  24. }