[DEVEXPRESS/WINFORM] PivotGridField 클래스 : UnboundExpression 속성을 사용해 언바운드 필드 생성하기
DevExpress/WinForm 2020. 5. 3. 20:41728x90
반응형
728x170
▶ MainForm.cs
using System.Data.OleDb;
using DevExpress.Data;
using DevExpress.XtraEditors;
using DevExpress.XtraPivotGrid;
namespace TestProject
{
/// <summary>
/// 메인 폼
/// </summary>
public partial class MainForm : XtraForm
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Private
#region Field
/// <summary>
/// 연결
/// </summary>
private OleDbConnection connection;
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainForm()
/// <summary>
/// 생성자
/// </summary>
public MainForm()
{
InitializeComponent();
this.connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=nwind.mdb");
this.pivotGridControl.DataSource = OrderDetail.GetOrderDetailList(this.connection);
this.pivotGridControl.RetrieveFields();
this.pivotGridControl.Fields["OrderID"].Area = PivotArea.RowArea;
PivotGridField totalPriceField = new PivotGridField();
totalPriceField.Caption = "Actual Price";
totalPriceField.UnboundFieldName = "ActualPrice";
totalPriceField.Area = PivotArea.DataArea;
totalPriceField.UnboundType = UnboundColumnType.Decimal;
totalPriceField.UnboundExpression = string.Format
(
"[{0}] * [{1}] * (1 - [{2}])",
this.pivotGridControl.Fields["Quantity" ].ExpressionFieldName,
this.pivotGridControl.Fields["UnitPrice"].ExpressionFieldName,
this.pivotGridControl.Fields["Discount" ].ExpressionFieldName
);
this.pivotGridControl.Fields.Add(totalPriceField);
this.pivotGridControl.BestFit();
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
댓글을 달아 주세요