DevExpress에서 TreeList에서 노드 추가하기 입니다.

 

TreeList에서 노드 추가한 결과 입니다.

using System.Windows.Forms;

using DevExpress.XtraEditors;
using DevExpress.XtraLayout;
using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.Columns;
using DevExpress.XtraTreeList.Nodes;

namespace DevTestForm
{
    /// <summary>
    /// 메인폼 클래스 입니다.
    /// </summary>
    public partial class MainForm : Form
    {   
        // Constructor (Public)

        #region MainForm() - 생성자 입니다.

        /// <summary>
        /// 생성자 입니다.
        /// </summary>
        public MainForm()
        {
            InitializeComponent();

            CreateColumns(this.devTreeList);
            CreateNodes(this.devTreeList);

            #region 이벤트를 설정합니다.

            #endregion
        }

        #endregion


        #region CreateColumns(treeList) - 컬럼을 생성합니다.

        /// <summary>
        /// 컬럼을 생성합니다.
        /// </summary>
        /// <param name="treeList">TreeList 입니다.</param>
        private void CreateColumns(TreeList treeList)
        { 
            treeList.BeginUpdate();

            TreeListColumn column1 = treeList.Columns.Add();
            column1.Caption      = "Customer";
            column1.VisibleIndex = 0;

            TreeListColumn column2 = treeList.Columns.Add();
            column2.Caption      = "Location";
            column2.VisibleIndex = 1;

            TreeListColumn column3 = treeList.Columns.Add();
            column3.Caption      = "Phone";
            column3.VisibleIndex = 2;

            treeList.EndUpdate();
        }

        #endregion

        #region CreateNodes(treeList)

        /// <summary>
        /// 노드를 생성합니다.
        /// </summary>
        /// <param name="treeList">TreeList 입니다.</param>
        private void CreateNodes(TreeList treeList)
        { 
            treeList.BeginUnboundLoad();

            TreeListNode parentForRootNodes = null;
            TreeListNode rootNode = treeList.AppendNode
            (
                new object[]{"AAAAAA", "BBBBBB", "000-0000-0000"}, parentForRootNodes
            );

            treeList.AppendNode
            (
                new object[] { "CCCCCC", "DDDDDDD", "1111-1111-1111" }, rootNode
            );

            treeList.AppendNode
            (
                new object[] { "ABB", "ADDADA", "222-2222-1111" }, rootNode
            );

            treeList.EndUnboundLoad();
        }

        #endregion

    }
}

+ Recent posts