-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
48 lines (43 loc) · 1.66 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
using System.Windows.Forms;
using DevExpress.XtraPivotGrid;
using System.Collections;
using System.Linq;
using System;
namespace WinFormsPivotGridCustomOLAPSort
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
// Creates a new collection of OLAP member properties.
fieldProduct.AutoPopulatedProperties = new string[] { "Color", "Class", "List Price" };
//Sets a field's sort mode to Custom to raise the CustomServerModeSort event.
fieldProduct.SortMode = PivotSortMode.Custom;
}
private void pivotGridControl1_CustomServerModeSort(object sender,
CustomServerModeSortEventArgs e)
{
if (e.Field == fieldProduct)
{
// Sets the result of comparing the "Product" field's values
// by the "Color" OLAP member property.
e.Result = Comparer.Default.Compare(
e.OLAPMember1.AutoPopulatedProperties["List Price"].Value,
e.OLAPMember2.AutoPopulatedProperties["List Price"].Value
);
}
}
private void pivotGridControl1_FieldValueDisplayText(object sender,
PivotFieldDisplayTextEventArgs e)
{
if (e.Field == fieldProduct)
{
IOLAPMember currentMember =
e.Field.GetOLAPMembers().First(m => Object.Equals(m.Value, e.Value));
e.DisplayText +=
string.Format(" ({0:C2})", currentMember.AutoPopulatedProperties["List Price"].Value);
}
}
}
}