Winform 加载时各事件的顺序(一)

Winform 加载时各事件的顺序

using System;
using System.Windows.Forms;

namespace WindowsFormsApp12
{
    /*
        1
        13
        14
        5
        6
        5
        6
        2
        7
        11
        12
        8
        9
        10
        3
        4
        15
        16
     */
    public partial class Form1 : Form
    {
        public Form1()
        {
            Console.WriteLine("1");
            InitializeComponent();
            Console.WriteLine("2");
        }
        protected override void OnActivated(EventArgs e)
        {
            Console.WriteLine("3");
            base.OnActivated(e);
            Console.WriteLine("4");
        }
        protected override void OnClientSizeChanged(EventArgs e)
        {
            Console.WriteLine("5");
            base.OnClientSizeChanged(e);
            Console.WriteLine("6");
        }
        protected override void OnCreateControl()
        {
            Console.WriteLine("7");
            base.OnCreateControl();
            Console.WriteLine("8");
        }
        protected override void OnGotFocus(EventArgs e)
        {
            Console.WriteLine("9");
            base.OnGotFocus(e);
            Console.WriteLine("10");
        }
        protected override void OnLoad(EventArgs e)
        {
            Console.WriteLine("11");
            base.OnLoad(e);
            Console.WriteLine("12");
        }
        protected override void OnResize(EventArgs e)
        {
            Console.WriteLine("13");
            base.OnResize(e);
            Console.WriteLine("14");
        }
        protected override void OnShown(EventArgs e)
        {
            Console.WriteLine("15");
            base.OnShown(e);
            Console.WriteLine("16");
        }
    }
}


作者最新文章
Winform TextBox (文本框) 密码输入框, 输入内容显示*号 (星号)
Winform 启动前弹出登录界面, 登录成功之后再显示主界面
C# 字符串string和字符数组char[]的相互转换
C# 字符串倒序输出, 实现字符串倒序的方法
Winform 如何从 TextBox(文本框) 控件读取每一行数据到数组