첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

TestProject.zip
다운로드

▶ ProjectObject.cs

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
    }
}

 

728x90

 

▶ StageObject.cs

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
    }
}

 

300x250

 

▶ TaskObject.cs

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

<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

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
    }
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요