CloseButton.cs 679 B

12345678910111213141516171819202122232425
  1. using System;
  2. using System.Windows.Forms;
  3. using UAS_MES_NEW.Properties;
  4. namespace UAS_MES_NEW.CustomControl.ButtonUtil
  5. {
  6. public partial class CloseButton : Button
  7. {
  8. public CloseButton()
  9. {
  10. InitializeComponent();
  11. this.Click += CloseButton_Click;
  12. this.Image = Resources._2_0btn_36;
  13. }
  14. private void CloseButton_Click(object sender, EventArgs e)
  15. {
  16. //获取打开窗体的集合,找到当前的Form的名称然后关闭
  17. FormCollection fmCollection = Application.OpenForms;
  18. Control c = this.Parent;
  19. fmCollection[c.Name].Close();
  20. }
  21. }
  22. }