Custom Designer for a Control

北城以北 提交于 2019-11-30 07:24:50
Jeff Yates

In order to add design-time functionality like additional operations (known as Action Lists and Verbs depending on how they are provided), or dragging of visual elements like headers or split bars, you need to implement a custom designer (usually derived from ControlDesigner) that allows the Windows Forms designer to understand how to interact with your custom control at design-time.

MSDN has a lengthy section on adding design-time support for your controls. It describes everything from type converters to extender providers and designer serialization to designer customization.

Additional resources

This article on CodeProject contains information on creating designers for custom controls. There are also some useful tips here and in this other StackOverflow question.

Only the Form and the UserControl classes have designers that allow you to edit their child controls at design time. Creating your own designer to give SplitContainer the same behavior is not exactly simple, most of all because it is so poorly documented and difficult to debug. You'll need to study the framework code with Reflector to get it right.

Punt this problem, put the SplitContainer in a user control. Set its Dock property to Fill. Now it is easy.

When writing your control, you need to make sure to add design time logic to it.

See this (.NET 1.0) article on MSDN for some more details. Here is another article from 2003.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!