■ GridControl 클래스에서 언바운드 모드 트리를 사용하는 방법을 보여준다.
▶ ProjectObject.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
namespace TestProject { /// <summary> /// 프로젝트 오브젝트 /// </summary> public class ProjectObject { //////////////////////////////////////////////////////////////////////////////////////////////////// Property ////////////////////////////////////////////////////////////////////////////////////////// Public #region 명칭 - Name /// <summary> /// 명칭 /// </summary> public string Name { get; set; } #endregion #region 실행자 - Executor /// <summary> /// 실행자 /// </summary> public string Executor { get; set; } #endregion } } |
▶ StageObject.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
namespace TestProject { /// <summary> /// 스테이지 오브젝트 /// </summary> public class StageObject { //////////////////////////////////////////////////////////////////////////////////////////////////// Property ////////////////////////////////////////////////////////////////////////////////////////// Public #region 명칭 - Name /// <summary> /// 명칭 /// </summary> public string Name { get; set; } #endregion #region 실행자 - Executor /// <summary> /// 실행자 /// </summary> public string Executor { get; set; } #endregion } } |
▶ TaskObject.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
namespace TestProject { /// <summary> /// 작업 오브젝트 /// </summary> public class TaskObject { //////////////////////////////////////////////////////////////////////////////////////////////////// Property ////////////////////////////////////////////////////////////////////////////////////////// Public #region 명칭 - Name /// <summary> /// 명칭 /// </summary> public string Name { get; set; } #endregion #region 실행자 - Executor /// <summary> /// 실행자 /// </summary> public string Executor { get; set; } #endregion #region 상태 - State /// <summary> /// 상태 /// </summary> public string State { get; set; } #endregion } } |
▶ MainWindow.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
<Window x:Class="TestProject.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" xmlns:local="clr-namespace:TestProject" Width="800" Height="600" Title="GridControl 클래스 : 언바운드 모드 트리 사용하기" FontFamily="나눔고딕코딩" FontSize="16"> <Grid> <dxg:GridControl Name="grid"> <dxg:GridControl.Columns> <dxg:GridColumn FieldName="Name" /> <dxg:GridColumn FieldName="Executor" /> <dxg:GridColumn FieldName="State" /> </dxg:GridControl.Columns> <dxg:GridControl.View> <dxg:TreeListView Name="treeListView" AutoWidth="True"> <dxg:TreeListView.Nodes> <dxg:TreeListNode> <dxg:TreeListNode.Content> <local:ProjectObject Name="Project : Betaron" Executor="Destiny Tabisola" /> </dxg:TreeListNode.Content> <dxg:TreeListNode.Nodes> <dxg:TreeListNode> <dxg:TreeListNode.Content> <local:StageObject Name="Development" Executor="Kairra Hogg" /> </dxg:TreeListNode.Content> <dxg:TreeListNode.Nodes> <dxg:TreeListNode> <dxg:TreeListNode.Content> <local:TaskObject Name="Coding" Executor="Sabato Durley" State="Not Started" /> </dxg:TreeListNode.Content> </dxg:TreeListNode> </dxg:TreeListNode.Nodes> </dxg:TreeListNode> </dxg:TreeListNode.Nodes> </dxg:TreeListNode> </dxg:TreeListView.Nodes> </dxg:TreeListView> </dxg:GridControl.View> </dxg:GridControl> </Grid> </Window> |
▶ MainWindow.xaml.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
using System.Windows; using DevExpress.Xpf.Grid; namespace TestProject { /// <summary> /// 메인 윈도우 /// </summary> public partial class MainWindow : Window { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainWindow() /// <summary> /// 생성자 /// </summary> public MainWindow() { InitializeComponent(); BuildTree(); this.treeListView.ExpandAllNodes(); } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private #region 트리 구축하기 - BuildTree() /// <summary> /// 트리 구축하기 /// </summary> private void BuildTree() { TreeListNode rootNode = GetRootTreeListNode(new ProjectObject() { Name = "Project : Stanton", Executor = "Nicholas Llams" }); TreeListNode childNode = GetChildTreeListNode(rootNode, new StageObject() { Name = "Information Gathering", Executor = "Ankie Galva" }); GetChildTreeListNode(childNode, new TaskObject() { Name = "Design", Executor = "Reardon Felton", State = "In progress" }); } #endregion #region 루트 트리 리스트 노드 구하기 - GetRootTreeListNode(content) /// <summary> /// 루트 트리 리스트 노드 구하기 /// </summary> /// <param name="content">컨텐트</param> /// <returns>루트 트리 리스트 노드</returns> private TreeListNode GetRootTreeListNode(object content) { TreeListNode node = new TreeListNode(content); treeListView.Nodes.Add(node); return node; } #endregion #region 자식 트리 리스트 노드 구하기 - GetChildTreeListNode(parentNode, content) /// <summary> /// 자식 트리 리스트 노드 구하기 /// </summary> /// <param name="parentNode">부모 노드</param> /// <param name="content">컨텐츠</param> /// <returns>자식 노드</returns> private TreeListNode GetChildTreeListNode(TreeListNode parentNode, object content) { TreeListNode childeNode = new TreeListNode(content); parentNode.Nodes.Add(childeNode); return childeNode; } #endregion } } |