【问题标题】:Create folder tree, Windows Forms创建文件夹树,Windows 窗体
【发布时间】:2014-04-28 18:21:53
【问题描述】:

我是 C# 和 Windows 窗体的新手,想创建一个像这样的简单 UI。

我有以下数组:

string [] projects;
string [] subjects;  
string [] experiments;
string [] scans;
string [] files; 

编辑:每个子元素都有指示它属于哪个父元素的信息(这可能使其更适合Subject [] subjects, Experiment [] experiments等的排列)

Windows 窗体组件必须以这种方式工作

projects  (<- when clicked should show the string array of projects)
|
|--- subjects (<- when clicked should show the string array of subjects)
        |
        |---experiments (<- when clicked should show the string array of experiments)
               |
               |--- scans (<- when clicked should show the string array of scans)
                      |
                      |----files (<- when clicked should show the string array of files)

我认为 TreeView component 符合要求,但由于我是 Windows 窗体的新手(以及如何完成这件事快速),我想我最好先检查一下。

TreeView 是实现此 UI 的适当方式吗?

【问题讨论】:

  • treeview 很好。用法见dotnetperls.com/treeview。但是您的数组布局“不合适”,因为它不包含有关实际父元素的信息 - 最好看看复合模式:en.wikipedia.org/wiki/Composite_pattern
  • 谢谢,我实际上有信息表明每个孩子属于哪个父组件,我认为这会使安排合适。

标签: c# winforms user-interface treeview


【解决方案1】:

是的。 Treeview 是满足您需求的最佳组件。

您也可以将此组件与 XML 文件一起使用。

有关更多信息,请查看以下链接:

http://www.dotnetperls.com/treeview

http://msdn.microsoft.com/pt-br/library/system.windows.forms.treeview(v=vs.110).aspx

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-03-19
    • 2012-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-05
    相关资源
    最近更新 更多