반응형
1. DevExpress DataGrid Master-Detail Mode #2
- 스크립트(Script)를 통한 DataGrid Master-Detail 만들기입니다.
(1) 소스
using System;
using System.Collections;
using System.ComponentModel.DataAnnotations;
namespace DXDataGridMasterDetailApp {
public partial class Form1 : DevExpress.XtraEditors.XtraForm {
public Form1() {
InitializeComponent();
// Binds the Data Grid to a data source (ArrayList descendant).
gridControl1.DataSource = new Orders();
}
}
public class Orders : ArrayList {
public Orders() {
Add(new Order(new ArrayList() {
new Product(){ ProductName = "Product A-1", Price = 78.99 },
new Product(){ ProductName = "Product A-2", Price = 199.99 },
new Product(){ ProductName = "Product A-3", Price = 18.99 },
}) { OrderName = "Order A", OrderDate = DateTime.Today } );
Add(new Order(new ArrayList() {
new Product(){ ProductName = "Product B-1", Price = 25.99 },
new Product(){ ProductName = "Product B-2", Price = 277.99 },
new Product(){ ProductName = "Product B-3", Price = 10.99 },
}) { OrderName = "Order B", OrderDate = DateTime.Today });
Add(new Order(new ArrayList() {
new Product(){ ProductName = "Product C-1", Price = 5.99 },
new Product(){ ProductName = "Product C-2", Price = 14.99 },
new Product(){ ProductName = "Product C-3", Price = 77.99 },
}) { OrderName = "Order C", OrderDate = DateTime.Today });
}
public virtual new Order this[int index] {
get {
return (Order)base[index];
}
}
}
public class Order {
ArrayList products;
public Order(ArrayList productsList) {
products = productsList;
}
public string OrderName { get; set; }
public DateTime OrderDate { get; set; }
public ArrayList Products {
get { return products; }
set { products = value; }
}
}
public class Product {
public string ProductName { get; set; }
[DisplayFormat(DataFormatString = "c2")]
public double Price { get; set; }
}
}
(2) 결과화면

반응형
'개발(IT) > DevExpress(WinForm)' 카테고리의 다른 글
DevExpress DataGrid Master-Detail Scripts (Examples #3) (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 |