■ PivotGridControl 클래스의 CustomDrawFieldValue 이벤트를 사용해 필드 값 헤더 모양을 변경하는 방법을 보여준다.
▶ MainForm.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
using System; using System.Data; using System.Drawing; using DevExpress.XtraEditors; using DevExpress.XtraPivotGrid; namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : XtraForm { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainForm() /// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent(); this.pivotGridControl.OptionsView.RowTreeWidth = 150; DataTable table = this.dataSet.Tables["Data"]; table.Rows.Add(new object[] { "UK" , DateTime.Today.AddYears(-1) , 4 , 5 }); table.Rows.Add(new object[] { "UK" , DateTime.Today.AddYears(-1).AddDays(1), 2 , 8 }); table.Rows.Add(new object[] { "USA" , DateTime.Today.AddYears(-1) , 3 , 9 }); table.Rows.Add(new object[] { "USA" , DateTime.Today.AddDays(1).AddYears(-1), 1 , 5 }); table.Rows.Add(new object[] { "France", DateTime.Today.AddYears(-1) , 8 , 3 }); table.Rows.Add(new object[] { "France", DateTime.Today.AddDays(1).AddYears(-1), 22 }); table.Rows.Add(new object[] { "UK" , DateTime.Today , 7 , 3 }); table.Rows.Add(new object[] { "UK" , DateTime.Today.AddDays(1) , 4 , 1 }); table.Rows.Add(new object[] { "USA" , DateTime.Today , 12, 6 }); table.Rows.Add(new object[] { "USA" , DateTime.Today.AddDays(1) , 14, 7 }); table.Rows.Add(new object[] { "France", DateTime.Today , 11, 1 }); table.Rows.Add(new object[] { "France", DateTime.Today.AddDays(1) , 10, 3 }); this.pivotGridControl.RefreshData(); this.pivotGridControl.BestFitColumnArea(); this.pivotGridControl.CustomDrawFieldValue += pivotGridControl_CustomDrawFieldValue; } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private #region 피벗 그리드 컨트롤 필드 값 커스텀 그리기 - pivotGridControl_CustomDrawFieldValue(sender, e) /// <summary> /// 피벗 그리드 컨트롤 필드 값 커스텀 그리기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void pivotGridControl_CustomDrawFieldValue(object sender, PivotCustomDrawFieldValueEventArgs e) { if(e.Area == PivotArea.ColumnArea) { e.Appearance.BackColor = Color.GreenYellow; } else if(e.Area == PivotArea.RowArea) { e.Painter.DrawObject(e.Info); e.Painter.DrawIndicator(e.Info); e.GraphicsCache.FillRectangle(e.GraphicsCache.GetSolidBrush(Color.FromArgb(50, 0, 0, 200)), e.Bounds); e.Handled = true; } } #endregion } } |