-
Notifications
You must be signed in to change notification settings - Fork 2
/
Form1.cs
53 lines (48 loc) · 1.67 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
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.Columns;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
private DataColumn _KeyField;
private DataTable _Tbl;
private MyCache _Cache = new MyCache("ID");
private DataTable CreateTable(int RowCount)
{
_Tbl = new DataTable();
_KeyField = _Tbl.Columns.Add("ID", typeof(int));
_KeyField.ReadOnly = true;
_KeyField.AutoIncrement = true;
_Tbl.Columns.Add("Name", 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[] { null, String.Format("Name{0}", i), 3 - i, DateTime.Now.AddDays(i) });
return _Tbl;
}
public Form1()
{
InitializeComponent();
gridControl1.DataSource = CreateTable(20);
CreateUnboundColumn();
}
private void CreateUnboundColumn()
{
GridColumn col = gridView1.Columns.AddVisible("Unbound", "Unbound column");
col.UnboundType = DevExpress.Data.UnboundColumnType.String;
}
private void gridView1_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
{
if (e.IsGetData)
e.Value = _Cache.GetValue(e.Row);
if (e.IsSetData)
_Cache.SetValue(e.Row, e.Value);
}
}
}