This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
/
Form1.cs
72 lines (61 loc) · 2.86 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
using System;
using System.Collections.Generic;
using System.Data;
using System.Windows.Forms;
using DevExpress.Data;
using DevExpress.Sparkline;
using DevExpress.XtraEditors.Repository;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.Base;
namespace SparklineInGrid {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
// Fill a grid's data source.
this.customersPaymentTableAdapter.Fill(this.contactsDataSet.CustomersPayment);
// Create a Sparkline repository item, adjust it and add it to the grid's repository.
RepositoryItemSparklineEdit repositoryItemSparklineEdit1 = new RepositoryItemSparklineEdit();
LineSparklineView lineSparklineView1 = repositoryItemSparklineEdit1.View as LineSparklineView;
lineSparklineView1.HighlightEndPoint = true;
lineSparklineView1.HighlightMaxPoint = true;
lineSparklineView1.HighlightMinPoint = true;
lineSparklineView1.HighlightStartPoint = true;
this.gridControl1.RepositoryItems.Add(repositoryItemSparklineEdit1);
// Create an unbound column, adjust it and add it to the grid view.
GridColumn colPayments = new GridColumn();
colPayments.Visible = true;
colPayments.Caption = "Payments";
colPayments.UnboundType = UnboundColumnType.Object;
colPayments.ColumnEdit = repositoryItemSparklineEdit1;
colPayments.FieldName = "gridColumn1";
colPayments.MaxWidth = 300;
colPayments.MinWidth = 50;
colPayments.Width = 255;
this.gridView1.Columns.Add(colPayments);
// Expand all groups for better initial navigation.
this.gridView1.ExpandAllGroups();
}
private void gridView1_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e) {
// Obtaining data for the sparkline editor.
if (e.IsGetData) {
List<double> values = new List<double>();
DataRowView row = (DataRowView)e.Row;
values.Add((double)row["January"]);
values.Add((double)row["February"]);
values.Add((double)row["March"]);
values.Add((double)row["April"]);
values.Add((double)row["May"]);
values.Add((double)row["June"]);
values.Add((double)row["July"]);
values.Add((double)row["August"]);
values.Add((double)row["September"]);
values.Add((double)row["October"]);
values.Add((double)row["November"]);
values.Add((double)row["December"]);
e.Value = values;
}
}
}
}