开发者

Editing Custom Controls or Panels in the Designer environment

I have created a custom control tha开发者_如何学Ct inherits System.Windows.Forms.Panel, and adds a few extra properties. I then intend to create child classes that inherit this custom-panel class, and add content to them.

The custom-panel class will be passed to a "Wizard" framework (with back/next buttons) as the content for the various steps. I intend to make extensive use of this, creating 40-50 different pages for Wizards to handle various things in my project.

Question: Is there a way to view just the panel in the Designer, and modify its layout and design from there? I could code everything the hard way, but I really don't want to.

I did some searching and found this article, but that discusses creating a custom control and adding it to a library. I don't need to do this, I just want to view/edit the control in Designer directly, without adding it to a Form.


Obvious Answer to the rescue again.

Create a custom control, add the layout/split panel as desired, and change it's property to DockStyle.Fill.

This makes your custom control "behave" like the layout control, as long as you add all other controls to the layout control.


add first this name space

using System.ComponentModel.Design;

Apply the System.ComponentModel.DesignerAttribute attribute to the control as follows:

[Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))] 
public class UserControl1 : System.Windows.Forms.UserControl
{
      ...
}

now you can edit your custom user control in designer environment

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜