Form3.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 WindowsFormsDemo1
  11. {
  12. public partial class Form3 : Form
  13. {
  14. public Form3()
  15. {
  16. InitializeComponent();
  17. }
  18. private void Form3_Click(object sender, EventArgs e)
  19. {
  20. MessageBox.Show("你好");
  21. }
  22. private void Form3_FormClosing(object sender, FormClosingEventArgs e)
  23. {
  24. DialogResult dr = MessageBox.Show("是否关闭窗体","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Warning);
  25. if (dr == DialogResult.Yes)
  26. {
  27. e.Cancel = false; //false表示执行关闭操作
  28. }
  29. else {
  30. e.Cancel = true; //true表示不执行关闭窗体,即不关闭窗体
  31. }
  32. }
  33. private void Form3_Load(object sender, EventArgs e)
  34. {
  35. Form2 f2 = new Form2(); //实例化Form2窗体
  36. f2.Show();
  37. f2.MdiParent = this; //this就表示当前的实例,也就是Form3
  38. Form1 f1 = new Form1();
  39. f1.Show();
  40. f1.MdiParent = this;
  41. Form4 f4 = new Form4();
  42. f4.Show();
  43. f4.MdiParent = this;
  44. }
  45. private void 水平平铺ToolStripMenuItem_Click(object sender, EventArgs e)
  46. {
  47. LayoutMdi(MdiLayout.TileHorizontal);
  48. }
  49. private void 垂直平铺ToolStripMenuItem_Click(object sender, EventArgs e)
  50. {
  51. LayoutMdi(MdiLayout.TileVertical);
  52. }
  53. }
  54. }