Control添加和设计模式 [英] ControlAdded and Design Mode

查看:74
本文介绍了Control添加和设计模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.

我正在创建一个ContainerControl,它将管理自定义布局方案.我正在尝试在ControlAdded事件中执行某些操作,例如调整大小,停靠,锚定等.

代码运行良好,如果MessageBox 冻结了该过程,则可以看到在设计器中一切正常,直到事件触发后.

触发事件完成后,则会将默认值分配给添加的Control .

有什么方法可以阻止事件后分配这些默认值,还是我会以错误的方式进行操作?

谢谢.

Hi all.

I am creating a ContainerControl that will manage a custom layout scheme. I am trying to do some things such as sizing, docking, anchoring, etc. in the ControlAdded event.

The code works well, and if the process is frozen by a MessageBox I can see that everything works well in the designer, until AFTER the event has fired.

When the event is done firing, THEN default values are assigned to the Control that was added.

Is there some way I can either stop these default values from being assigned after my event, or am I going about this the wrong way?

Thanks.

推荐答案

重置值是什么?在属性设置器上设置一个断点,看看谁在调用它.

它可能是您父表单的设计者代码.如果是这样,您可以挂钩Control.Load事件而不是Control.ControlAdded.

尼克
What is resetting the values? Set a breakpoint on a property setter and see who is calling it.

It is probably the designer code of your parent form. If so, you could hook the Control.Load event instead of Control.ControlAdded.

Nick


这篇关于Control添加和设计模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆