如何在自定义的WinForms控制限制客户端控制区 [英] How to restrict client control area in a custom WinForms control

查看:170
本文介绍了如何在自定义的WinForms控制限制客户端控制区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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

  3. 从被拖到标题区域

    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.

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

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

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

  3. 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.

这篇关于如何在自定义的WinForms控制限制客户端控制区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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