简体   繁体   English

Visual Studio中没有父窗体的设计面板

[英]design panel without parent form in Visual Studio

Anyone come up with a way that I can design a panel without a form? 有人想出一种方法,我可以设计一个没有表格的面板吗?

On the surface usercontrol doesn't seem the way to go. 从表面上看,用户控制似乎不太可行。

Background: I come from a text editor world and VS is new to me. 背景:我来自文本编辑器世界,VS对我来说是新手。 We did everything with panels instead of forms. 我们用面板而不是表格做了一切。 So open for learning. 所以开放学习。 Specifically have a base class panel (ExtendedPanel) that defines some basic controls: Cancel, Save, Save and Close. 特别是有一个基类面板(ExtendedPanel),它定义了一些基本控件:取消,保存,保存和关闭。 This ExtendedPanel then will be used for ClientExtendedPanel that is tied to a bindingsouce clientBindingSource. 然后,此ExtendedPanel将用于绑定到bindingsouce clientBindingSource的ClientExtendedPanel。 This is all tied to my entity framework model. 这都与我的实体框架模型有关。 So I will add, edit and delete sql datarows for my Client table. 所以我将为我的Client表添加,编辑和删除sql datarows。 If no changes have happened by Save button will not be enabled. 如果“保存”按钮未发生任何更改,则不会启用。 If I make a change but hit cancel it will warn me. 如果我做出改变但点击取消它会警告我。 I've done all this before but since I left that company I don't have access to the code base and they didn't use VS (text editor only)so it wasn't really transportable anyway. 我之前已经完成了所有这些,但是因为我离开了那家公司,我无法访问代码库而且他们没有使用VS(仅限文本编辑器)所以它无论如何都不是真正可以运输的。

All that background so I can ask: Is usercontrol the way to go, or is there something that will allow me to visually add controls to a panel like it is a form? 所有这些背景让我可以问:用户控制是否可行,或者是否有某些东西可以让我直观地将控件添加到面板中,就像它是一个表单一样?

Yes, a UserControl provides a form-like canvas in the designer for you to add other controls (buttons, etc). 是的,UserControl在设计器中提供了一个类似于窗体的画布,您可以添加其他控件(按钮等)。

You can do this too by inheriting a panel and writing the code to add the buttons and wire their events, etc, but you won't get the designer support. 也可以通过继承一个面板并编写代码来添加按钮和连接他们的事件等做到这一点,但你不会得到设计师的支持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM