첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

■ TreeListControl 클래스 : TOTAL SUMMARY 표시하기

------------------------------------------------------------------------------------------------------------------------


TestProject.zip


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"

    Width="800"

    Height="600"

    Title="TOTAL SUMMARY 표시하기"

    FontFamily="나눔고딕코딩"

    FontSize="16">

    <Grid>

        <dxg:TreeListControl x:Name="treeListControl"

            AutoPopulateColumns="True">

            <dxg:TreeListControl.View>

                <dxg:TreeListView x:Name="treeListView"

                    KeyFieldName="ID"

                    ParentFieldName="ParentID"

                    ShowTotalSummary="True" />

            </dxg:TreeListControl.View>

            <dxg:TreeListControl.TotalSummary>

                <dxg:TreeListSummaryItem

                    FieldName="Name"

                    SummaryType="Count" />

            </dxg:TreeListControl.TotalSummary>

        </dxg:TreeListControl>

    </Grid>

</Window>

 

 

MainWindow.xaml.cs

 

 

using System.Windows;

 

using DevExpress.Data;

using DevExpress.Xpf.Grid;

 

namespace TestProject

{

    /// <summary>

    /// 메인 윈도우

    /// </summary>

    public partial class MainWindow : Window

    {

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor

        ////////////////////////////////////////////////////////////////////////////////////////// Public

 

        #region 생성자 - MainWindow()

 

        /// <summary>

        /// 생성자

        /// </summary>

        public MainWindow()

        {

            InitializeComponent();

 

            this.treeListControl.ItemsSource = new EmployeeList().GetData();

 

            this.treeListControl.View.ExpandAllNodes();

 

            CreateTotalSummary("Age", SummaryItemType.Min    );

            CreateTotalSummary("Age", SummaryItemType.Max    );

            CreateTotalSummary("Age", SummaryItemType.Average);

        }

 

        #endregion

 

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method

        ////////////////////////////////////////////////////////////////////////////////////////// Private

 

        #region TOTAL SUMMARY 생성하기 - CreateTotalSummary(fieldName, summaryItemType)

 

        /// <summary>

        /// TOTAL SUMMARY 생성하기

        /// </summary>

        /// <param name="fieldName">필드명</param>

        /// <param name="summaryItemType">SUMMARY 항목 타입</param>

        private void CreateTotalSummary(string fieldName, SummaryItemType summaryItemType)

        {

            TreeListSummaryItem treeListSummaryItem = new TreeListSummaryItem()

            {

                FieldName    = fieldName      ,

                SummaryType  = summaryItemType,

                ShowInColumn = fieldName

            };

 

            this.treeListControl.TotalSummary.Add(treeListSummaryItem);

        }

 

        #endregion

    }

}

 

------------------------------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker

댓글을 달아 주세요