-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
75 lines (65 loc) · 2.87 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
73
74
75
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraGrid.Views.Base;
namespace Q148684 {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
InitializePopupControls();
}
private List<bool> unboundData = new List<bool>();
private void Form1_Load(object sender, EventArgs e) {
// TODO: This line of code loads data into the 'nwindDataSet.Orders' table. You can move, or remove it, as needed.
this.ordersTableAdapter.Fill(this.nwindDataSet.Orders);
order_DetailsTableAdapter1.Fill(nwindDataSet.Order_Details);
InitializeUnboundData();
}
private SimpleDetailEditor simpleEditor;
private GridDetailEditor gridEditor;
private Size SimpleEditorSize = new Size(202, 136);
private Size GridEditorSize = new Size(403, 218);
private void InitializePopupControls() {
simpleEditor = new SimpleDetailEditor();
simpleEditor.DataSource = ordersBindingSource;
simpleEditor.Dock = DockStyle.Fill;
gridEditor = new GridDetailEditor();
gridEditor.DataSource = ordersBindingSource;
gridEditor.Dock = DockStyle.Fill;
detailsEdit.PopupControl = new PopupContainerControl();
}
private void InitializeUnboundData() {
for (int i = 0; i < nwindDataSet.Orders.Count; i++)
unboundData.Add(i % 2 == 0);
}
private void OnDetailsEditQueryPopup(object sender, CancelEventArgs e) {
PopupContainerEdit edit = (PopupContainerEdit)sender;
if ((bool)gridView1.GetFocusedRowCellValue(colUseGrid)) {
edit.Properties.PopupControl.Controls.Add(gridEditor);
edit.Properties.PopupControl.Size = GridEditorSize;
} else {
edit.Properties.PopupControl.Controls.Add(simpleEditor);
edit.Properties.PopupControl.Size = SimpleEditorSize;
}
}
private void OnDetailsEditCloseUp(object sender, CloseUpEventArgs e) {
((PopupContainerEdit)sender).Properties.PopupControl.Controls.Clear();
}
private void OnGridViewCustomUnboundColumnData(object sender, CustomColumnDataEventArgs e) {
if (e.Column == colUseGrid)
if (e.IsGetData)
e.Value = unboundData[e.ListSourceRowIndex];
else if (e.IsSetData)
unboundData[e.ListSourceRowIndex] = (bool)e.Value;
}
private void OnDetailsEditQueryDisplayText(object sender, QueryDisplayTextEventArgs e) {
e.DisplayText = "Edit Details";
}
}
}