我正在尝试制作我自己的用户控件并且几乎完成了它,只是想添加一些润色。我希望设计器中的选项“停靠在父容器中”。有谁知道如何做到这一点我找不到例子。我认为这与停靠属性有关。
最佳答案
我还建议查看 DockingAttribute .
[Docking(DockingBehavior.Ask)]
public class MyControl : UserControl
{
public MyControl() { }
}
这还会在控件的右上角显示“操作箭头”。
此选项早在 .NET 2.0 就可用,如果您只需要“在父容器中停靠/取消停靠”功能,它就会简单得多。在这种情况下,Designer 类就大材小用了。
它还提供了 DockingBehavior.Never
和 DockingBehavior.AutoDock
选项。 Never
不显示箭头并以其默认的 Dock
行为加载新控件,而 AutoDock
显示箭头但自动将控件停靠在 as 填写
。
PS: Sorry about necromancing a thread. I was looking for a similar solution, and this was the first thing that popped up on Google. The Designer attributes gave me an idea, so I started digging around and found DockingAttribute, which seemed far cleaner than the accepted solution with the same requested results. Hopefully this will help someone in the future.
关于c# - 用户控制停靠属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/964421/