반응형
1. DevExpress DataGrid Master-Detail Mode #3
- 스크립트(Script)를 통한 DataGrid Master-Detail 만들기입니다.
(1) 소스
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace DXDataGridMasterDetailApp {
public partial class Form1 : DevExpress.XtraEditors.XtraForm {
public Form1() {
InitializeComponent();
gridControl1.DataSource = SampleData.GetData();
gridView1.MasterRowGetRelationCount += (s, e) => {
e.RelationCount = 1;
};
gridView1.MasterRowEmpty += (s, e) => {
e.IsEmpty = false;
};
gridView1.MasterRowGetChildList += (s, e) => {
e.ChildList = SampleData.GetData();
};
gridView1.MasterRowGetRelationName += (s, e) => {
e.RelationName = "Test Relation Name";
};
}
}
public class SampleData {
[Display(Order = -1)]
public int ID { get; set; }
public string Name { get; set; }
public double Length { get; set; }
public bool Mark { get; set; }
public DateTime RecordDate { get; set; }
public static List<SampleData> GetData() {
return new List<SampleData>() {
new SampleData(){ ID = 0, Name = "Bluehead Wrasse", Length = 15.09, Mark = false, RecordDate = DateTime.Now },
new SampleData(){ ID = 1, Name = "Ornate ButterflyFish", Length = 15.09, Mark = true, RecordDate = DateTime.Now },
new SampleData(){ ID = 2, Name = "Senorita", Length = 15.09, Mark = true, RecordDate = DateTime.Now },
new SampleData(){ ID = 3, Name = "Surf Smelt", Length = 15.09, Mark = false, RecordDate = DateTime.Now },
};
}
}
}
(2) 결과화면
반응형
'개발(IT) > DevExpress(WinForm)' 카테고리의 다른 글
DevExpress DataGrid Master-Detail Scripts (Examples #2) (0) | 2024.04.10 |
---|---|
DevExpress DataGrid Master-Detail Scripts (Examples #1) (0) | 2024.04.10 |
DevExpress 문서파일 분리작업 (0) | 2023.12.01 |
DevExpress Excel 열기 (0) | 2023.12.01 |
DevExpress Excel 열기/저장 #1 (0) | 2023.12.01 |