/
Form1.cs
88 lines (81 loc) · 3.1 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
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
86
87
88
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraPivotGrid.ViewInfo;
using DevExpress.XtraPivotGrid;
namespace WindowsApplication73
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
pivotGridControl1.DataSource = CreateTable(500);
pivotGridControl1.RetrieveFields();
pivotGridControl1.Fields["Order"].Area = PivotArea.RowArea;
pivotGridControl1.Fields["Type"].Area = PivotArea.ColumnArea;
pivotGridControl1.Fields["Number"].Area = PivotArea.DataArea;
}
private DataTable CreateTable(int RowCount)
{
DataTable tbl = new DataTable();
tbl.Columns.Add("Order", typeof(string));
tbl.Columns.Add("Type", typeof(string));
tbl.Columns.Add("Number", typeof(int));
tbl.Columns.Add("Date", typeof(DateTime));
for (int i = 0; i < RowCount; i++)
tbl.Rows.Add(new object[] { "Order "+ i % 7 , "Type " + i % 4, (i * 24) % 87 , DateTime.Now.AddDays(i) });
return tbl;
}
Point mousePos = new Point();
BaseViewInfo viewInfo;
int offset = 5;
private void pivotGridControl1_CustomDrawFieldValue(object sender, DevExpress.XtraPivotGrid.PivotCustomDrawFieldValueEventArgs e)
{
if (mousePos != Point.Empty && e.Bounds.Contains(mousePos))
{
e.Painter.DrawObject(e.Info);
Size rectSize = new Size(12, 12);
Point rectPos = new Point(e.Bounds.Right - rectSize.Width - offset, e.Bounds.Top + offset);
Rectangle rect = new Rectangle(rectPos, rectSize);
e.Graphics.FillRectangle(Brushes.Chartreuse, rect);
e.Handled = true;
}
}
private void pivotGridControl1_MouseMove(object sender, MouseEventArgs e)
{
mousePos = Point.Empty;
PivotGridHitInfo info = pivotGridControl1.CalcHitInfo(e.Location);
if (info.HitTest == PivotGridHitTest.Value)
{
mousePos = e.Location;
BaseViewInfo newVI = info.ValueInfo.Data.ViewInfo.GetViewInfoAtPoint(e.Location);
if (!object.ReferenceEquals(newVI, viewInfo))
{
pivotGridControl1.Invalidate(newVI.PaintBounds);
if (viewInfo != null)
pivotGridControl1.Invalidate(viewInfo.PaintBounds);
viewInfo = newVI;
}
}
else
{
if (viewInfo != null)
pivotGridControl1.Invalidate(viewInfo.PaintBounds);
viewInfo = null;
}
}
private void pivotGridControl1_MouseLeave(object sender, EventArgs e)
{
viewInfo = null;
mousePos = Point.Empty;
}
}
}