简体   繁体   English

C# WinForms - 如何创建类似 Visual Studio 项目属性的属性页

[英]C# WinForms - How to create a Properties Page like Visual Studio Project Properties

I'm trying to create a form that operates like the Visual Studio Properties page, with a list of categories (like Application, Build, Build Events etc) in a column on the left and corresponding information on the right.我正在尝试创建一个类似于 Visual Studio 属性页面的表单,在左侧的列中包含类别列表(如应用程序、构建、构建事件等),在右侧的列中包含相应的信息。 I'm planning to use either panels or a tabcontrol (with the tab header hidden) for the right hand side.我打算在右侧使用面板或选项卡控件(隐藏选项卡标题)。

However, I'm unsure how best to create the column of categories on the left.但是,我不确定如何最好地创建左侧的类别列。 Is there a standard control that provides this functionality?是否有提供此功能的标准控件? Otherwise, I considered using a panel containing Buttons, or individual Panels, or a ListBox, but I don't think these would give the same look.否则,我考虑使用包含按钮的面板、单个面板或列表框,但我认为它们不会给出相同的外观。 Also, I don't want to write code if a suitable control already exists.另外,如果已经存在合适的控件,我不想编写代码。

Ideally I would like to be able to easily disable all the categories, for example while editing a record on one page.理想情况下,我希望能够轻松禁用所有类别,例如在编辑一页上的记录时。

Having nested categories might be nice, but is not essential.嵌套类别可能很好,但不是必需的。

If the information on the right is not related to one another as you switch categories on the left, to create a good separation between categories I'd suggest you do the following:如果右侧的信息在您切换左侧的类别时彼此不相关,为了在类别之间建立良好的分离,我建议您执行以下操作:

  • Create a user control for each individual category为每个单独的类别创建一个用户控件
  • Split your form in two, the bar on the left and a panel on the right将表单一分为二,左侧的栏和右侧的面板
  • The bar on the left, for the categories, can be a list of radio buttons, or links, or whatever you like.左侧的栏,对于类别,可以是单选按钮列表、链接或任何你喜欢的。 I'd suggest a TreeView since it easily support sub-categories.我建议使用 TreeView,因为它可以轻松支持子类别。
  • As the user click on a category (by attaching a method to the corresponding even on the control used for the categories) you can remove the control from the panel, if any, and reset the control that corresponds to the selected category.当用户单击一个类别时(通过将一个方法附加到用于该类别的控件上的相应偶数上),您可以从面板中删除该控件(如果有),并重置与所选类别对应的控件。

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

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