피벗 그리드 컨트롤 가져오기
[도구 상자] - [Data & Analytics] 에서 PivotGridControl 을 끌어와 배치
피벗 그리드에 데이터 연결하기 (데이터베이스로 부터)
private void PivotGrid()
{
// 주어진 환경에 따라 데이터베이스 질의 결과를 테이터 셋(ds)으로 가지고 옵니다
pgcList.BeginUpdate();
pgcList.DataSource = ds.Tables[0];
// 행으로 나타낼 필드
PivotGridField fieldPV_CODE = new PivotGridField()
{
Area = PivotArea.RowArea,
AreaIndex = 0,
FieldName = "PV_CODE",
Caption = "장비코드",
};
// 열로 나타낼 필드
PivotGridField fieldPV_DATE = new PivotGridField()
{
Area = PivotArea.ColumnArea,
AreaIndex = 0,
FieldName = "PV_DATE",
Caption = "생산일자"
};
// 데이터 필드
PivotGridField fieldPV_QTY = new PivotGridField()
{
Area = PivotArea.DataArea,
AreaIndex = 0,
FieldName = "PV_QTY",
Caption = "불량수량",
};
fieldPV_QTY.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
fieldPV_QTY.CellFormat.FormatString = "n0";
// 위에서 정의한 필드로 피벗 구성
pgcList.Fields.Clear();
pgcList.Fields.AddRange(new PivotGridField[] {
fieldPV_CODE,
fieldPV_DATE,
fieldPV_QTY
});
pgcList.EndUpdate();
// 필터 항목은 설정하지 않았으므로 숨김
pgcList.OptionsView.ShowFilterHeaders = false;
}
피벗 그리드와 차트 연결하기 (Binding Chart with Pivot grid)
- 해당 차트의 스마트 태그를 클릭
- 아래 그림과 같이 데이터 소스를 피벗 그리드 컨트롤로 설정

- 프로그램을 실행 피벗 그리드의 셀을 클릭하면 동적으로 그래프가 변경됨을 확인할 수 있다
[참고 사이트]
데브익스프레스 : Pivot Grid
https://docs.devexpress.com/WindowsForms/3409/controls-and-libraries/pivot-grid