-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
56 lines (49 loc) · 1.7 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
using System;
using System.Collections.Generic;
using System.Drawing;
namespace GridBeforePrint
{
public partial class Form1 : DevExpress.XtraEditors.XtraForm
{
private List<Customer> customerList;
private List<Customer> GetData()
{
List<Customer> list = new List<Customer>();
for (int i = 0; i < 15; i++)
{
Customer customer = new Customer()
{
FirstName = string.Format("FirstName {0}", i),
LastName = string.Format("LastName {0}", i),
Id = i
};
list.Add(customer);
}
return list;
}
public Form1()
{
InitializeComponent();
myGridView1.OptionsView.ShowPreview = true;
myGridView1.OptionsView.AutoCalcPreviewLineCount = false;
myGridView1.PreviewFieldName = "FirstName";
customerList = GetData();
myGridControl1.DataSource = customerList;
this.Controls.Add(myGridControl1);
myGridView1.HeaderPrintEvent += MyGridView1_HeaderPrintEvent;
myGridView1.SamplePrintEvent += MyGridView1_SamplePrintEvent;
}
private void MyGridView1_SamplePrintEvent(object sender, SamplePrintEventArgs args)
{
args.Brick.Style.BackColor = Color.Pink;
}
private void MyGridView1_HeaderPrintEvent(object sender, HeaderPrintEventArgs args)
{
args.Brick.Style.BackColor = Color.PowderBlue;
}
private void simpleButton2_Click(object sender, EventArgs e)
{
myGridControl1.ShowPrintPreview();
}
}
}