This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
56 lines (52 loc) · 1.91 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.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid.Drawing;
using DevExpress.Utils.Drawing;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
private DevExpress.Utils.Drawing.HeaderObjectPainter _Painter;
private DataTable CreateTable(int RowCount)
{
DataTable tbl = new DataTable();
tbl.Columns.Add("Name", typeof(string));
tbl.Columns.Add("ID", typeof(int));
tbl.Columns.Add("Number", typeof(int));
tbl.Columns.Add("Date", typeof(DateTime));
for (int i = 0; i < RowCount; i++)
tbl.Rows.Add(new object[] { String.Format("Name{0}", i), i, 3 - i, DateTime.Now.AddDays(i) });
return tbl;
}
public Form1()
{
InitializeComponent();
gridControl1.DataSource = CreateTable(20);
advBandedGridView1.CustomDrawCell += advBandedGridView1_CustomDrawCell;
_Painter = new GridPainter(advBandedGridView1).ElementsPainter.Column;
}
void advBandedGridView1_CustomDrawCell(object sender, RowCellCustomDrawEventArgs e)
{
if (e.Column == gridColumn1)
{
e.Handled = true;
HeaderObjectInfoArgs args = new HeaderObjectInfoArgs();
Rectangle bounds = e.Bounds;
bounds.Inflate(1, 1);
args.Bounds = bounds;
args.Caption = e.DisplayText;
args.Cache = e.Cache;
bounds.Offset(-bounds.Location.X, -bounds.Location.Y);
args.CaptionRect = bounds;
args.Appearance.Assign(e.Appearance);
_Painter.DrawObject(args);
}
}
}
}