[DEVEXPRESS/WINFORM] TreeList 클래스 : ChildListFieldName 속성을 사용해 계층적 데이터 소스 사용하기
DevExpress/WinForm 2020. 5. 16. 12:32728x90
반응형
728x170
▶ MainForm.cs
using System;
using System.Collections.Generic;
using DevExpress.XtraEditors;
namespace TestProject
{
/// <summary>
/// 메인 폼
/// </summary>
public partial class MainForm : XtraForm
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainForm()
/// <summary>
/// 생성자
/// </summary>
public MainForm()
{
InitializeComponent();
Load += Form_Load;
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
//////////////////////////////////////////////////////////////////////////////// Event
#region 폼 로드시 처리하기 - Form_Load(sender, e)
/// <summary>
/// 폼 로드시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void Form_Load(object sender, EventArgs e)
{
Employee employee1 = new Employee() { JobTitle = "Chief Executive Officer" , Name = "Bruce Cambell" , City = "Oaks" };
Employee employee2 = new Employee() { JobTitle = "Information Services Manager", Name = "Cindy Haneline", City = "Vista" };
Employee employee3 = new Employee() { JobTitle = "Database Administrator" , Name = "Andrea Deville", City = "Aurora" };
Employee employee4 = new Employee() { JobTitle = "Application Specialist" , Name = "Anita Ryan" , City = "West" };
Employee employee5 = new Employee() { JobTitle = "Network Manager" , Name = "Anita Cardle" , City = "Glendale" };
Employee employee6 = new Employee() { JobTitle = "Network Administrator" , Name = "Andrew Carter" , City = "Moline" };
Employee employee7 = new Employee() { JobTitle = "Marketing Manager" , Name = "Carolyn Baker" , City = "Longview" };
employee1.SubordinatesList = new List<Employee>() { employee2, employee7 };
employee2.SubordinatesList = new List<Employee>() { employee3, employee4, employee5 };
employee5.SubordinatesList = new List<Employee>() { employee6 };
List<Employee> list = new List<Employee>();
list.Add(employee1);
this.treeList.ChildListFieldName = "SubordinatesList";
this.treeList.DataSource = list;
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
댓글을 달아 주세요