This repository has been archived by the owner on Sep 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VGridControlDescendant.cs
83 lines (68 loc) · 2.58 KB
/
VGridControlDescendant.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
73
74
75
76
77
78
79
80
81
82
83
using DevExpress.XtraEditors;
using DevExpress.XtraVerticalGrid;
namespace E4423
{
[System.ComponentModel.DesignerCategory("")]
public class VGridControlDescendant : VGridControl
{
public VGridControlDescendant()
{
EditingMode = false;
DataManager.VisualClient = this;
DataManager.DataClient = this;
DataManager.ValidationClient = this;
DataManager.CurrentClient = this;
DataManager.ListSourceChanged += OnDataManager_DataSourceChanged;
}
protected override DevExpress.XtraVerticalGrid.Data.VGridDataManager CreateDataManager() {
return new VGridDataManagerDescendant(this);
}
protected override DevExpress.XtraVerticalGrid.Painters.VGridPainter CreatePainterCore(DevExpress.XtraVerticalGrid.Painters.PaintEventHelper eventHelper)
{
return new CustomVGridPainter(eventHelper);
}
#region EventHandlerWhenAllowNew
public bool AllowNew { get; set; }
public bool CanRemoveLastCreated;
bool EditingMode;
protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs e)
{
base.OnKeyDown(e);
if (!AllowNew && ActiveEditor == null && CanRemoveLastCreated)
if (e.KeyCode == System.Windows.Forms.Keys.Escape)
{
this.DeleteRecord(RecordCount - 1);
AllowNew = true;
}
}
protected override void ChangeFocusedRecord(int curRecord)
{
if (EditingMode)
{
AllowNew = true;
EditingMode = false;
}
base.ChangeFocusedRecord(curRecord);
}
protected override void RaiseCellValueChanging(DevExpress.XtraVerticalGrid.Events.CellValueChangedEventArgs e)
{
base.RaiseCellValueChanging(e);
if (e.RecordIndex < 0)
{
this.HideEditor();
this.AllowNew = false;
this.AddNewRecord();
this.FocusedRecord = RecordCount - 1;
this.FocusedRecord = RecordCount - 1;
this.FocusedRecordCellIndex = e.CellIndex;
this.SetCellValue(e.Row, RecordCount - 1, e.Value);
this.ShowEditor();
if (this.ActiveEditor is TextEdit)
(this.ActiveEditor as TextEdit).DeselectAll();
EditingMode = true;
CanRemoveLastCreated = true;
}
}
#endregion
}
}