C# 用groupbox控件gpbWindows實現同窗體多界面切換

很多時候我們需要在程序一開始後立即觸發執行一些程序。這時候需要調用Form_Load。
首先編寫事件程序塊,編寫完後即可再裏面添加需要執行的代碼。
在結構體之後寫就行。添加之前的代碼如下:
這裏寫圖片描述
添加之後:
這裏寫圖片描述
然後註冊事件。我寫到窗體初始化之後。註冊語句如下:
這裏寫圖片描述

貼出代碼塊如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
using GxIAPINET;

namespace watchGlass
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.Load += new EventHandler(Form1_Load);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            
        }

        private void ButtonShutDown_Click(object sender, EventArgs e)
        {
            Process.Start("shutdown", "/s /t 0");
        }

        private void ButtonStart_Click(object sender, EventArgs e)
        {

        }
    }
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章