/
Form1.cs
54 lines (52 loc) · 2.23 KB
/
Form1.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
using DevExpress.XtraPivotGrid;
using System.Drawing;
using System.Windows.Forms;
namespace PivotCustomDraw {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
// This line of code is generated by Data Source Configuration Wizard
// Fill the ExcelDataSource
excelDataSource1.Fill();
}
private void pivotGridControl1_CustomDrawCell(object sender, PivotCustomDrawCellEventArgs e) {
Rectangle r;
// Paints Row Grand Totals.
if (e.RowValueType == PivotGridValueType.GrandTotal) {
Brush brushFillTotals;
brushFillTotals = e.GraphicsCache.GetSolidBrush(ColorTranslator.FromHtml("#0099cc"));
r = e.Bounds;
e.GraphicsCache.FillRectangle(brushFillTotals, e.Bounds);
r.Inflate(-4, -4);
e.GraphicsCache.DrawString(e.DisplayText, e.Appearance.Font,
Brushes.White, r, e.Appearance.GetStringFormat());
e.Handled = true;
return;
}
// Paints the data cells.
Brush brushFill;
r = e.Bounds;
if (e.Focused)
// Initializes the brush used to paint the focused cell.
brushFill = e.GraphicsCache.GetSolidBrush(Color.White);
else
if (e.Selected)
// Initializes the brush used to paint selected cells.
brushFill = e.GraphicsCache.GetSolidBrush(ColorTranslator.FromHtml("#b6e7eb"));
else
// Initializes the brush used to paint data cells.
brushFill = e.GraphicsCache.GetSolidBrush(ColorTranslator.FromHtml("#ecfbf8"));
e.GraphicsCache.DrawRectangle(Pens.DimGray, r);
r.Inflate(-1, -1);
e.GraphicsCache.FillRectangle(brushFill, r);
if (e.Focused) {
r.Inflate(-1, -1);
e.GraphicsCache.DrawRectangle(e.GraphicsCache.GetPen(ColorTranslator.FromHtml("#f05b41"),
3), r);
}
r.Inflate(-4, -4);
e.Appearance.DrawString(e.GraphicsCache, e.DisplayText, r);
e.Handled = true;
}
}
}