如何在自定义的WinForms控制限制客户端控制区控制区、自定义、客户端、如何在

2023-09-04 02:32:15 作者:你是我回忆里的绝版幸福

我有一个使用我从ParentControlDesigner继承,让孩子设计控件被丢弃自定义控件。我没有使用任何内部的设计师,只是简单的单亲东西。

此控件绘制一个头,所以我想要做的三件事情:

有子控件停靠时,设置为顶部或填写标题,而不是控件的顶部,底部的。

有子控件拖动鼠标,而不是控制的顶部时,捕捉到头部的底部。

从被拖到标题区域

prevent控制,期限(我有一种感觉,这是不可能的)。

(1)是最重要的 - 我知道这是可能的,因为我见过的其他控件做到这一点。 (2)也将是一个重大的帮助。 (3)我不关心那么多,这纯粹是不错的。

会有人能指出我在正确的方向上如何实施这些规则,不不必诉诸笨拙的子面板和InternalControlDesigner方法?

解决方案   

prevent被拖动控制   到标题区域,周期(我有一个   感觉这是不可能的)

具有控制(控制本身,而不是设计师)重写 Control.DisplayRectangle.get 可能有助于限制其孩子。

I have a custom control that uses a designer I've inherited from ParentControlDesigner to allow child controls to be dropped. I'm not using any internal designers, just straightforward single-parent stuff.

对已加密限制编辑的Excel工作表 Word文档移除密码的方法 软件综合讨论区 软件区

This control draws a "header", so I'm trying to do three things:

Have child controls dock to the bottom of the header instead of the top of the control, when set to Top or Fill.

Have child controls snap to the bottom of the header when dragging with the mouse, instead of the top of the control.

Prevent controls from being dragged onto the header area, period (I have a feeling this may not be possible).

(1) is the most important - I know it's possible because I've seen other controls that do it. (2) would also be a major help. (3) I don't care about that much, it would just be nice to have.

Would anyone be able to point me in the right direction on how to implement these rules, without having to resort to a clumsy sub-panel and the InternalControlDesigner methods?

解决方案

Prevent controls from being dragged onto the header area, period (I have a feeling this may not be possible)

Having the control (the control itself, not the designer) override Control.DisplayRectangle.get may help restrict its children.