简体   繁体   English

自定义面板用户控件上的布局事件

[英]Layout Event on a custom Panel User Control

I'm currently working on a custom user control inheriting from a panel, I'm trying to hook on the Layout event of the Panel to do a certain action.我目前正在处理从面板继承的自定义用户控件,我试图挂钩面板的 Layout 事件以执行特定操作。 I don't want to override the initial Layout event, I just want to hook on it and add stuffs to do我不想覆盖初始的 Layout 事件,我只想挂上它并添加要做的事情

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

namespace SamsonLogiciel
{
    public partial class StretchPanel : Panel
    {
        public StretchPanel()
        {
            InitializeComponent();
        }
    }
}
protected override void OnLayout(LayoutEventArgs levent)
{
    // your code here
    base.OnLayout(levent);
}

Just add this to your StretchPanel class.只需将此添加到您的StretchPanel类。 You can add your own code to "hook" into it, and then you call base.OnLayout so that you don't override the default stuff.您可以将自己的代码添加到“挂钩”中,然后调用base.OnLayout以免覆盖默认内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM