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
211 lines (202 loc) · 6.81 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Grid;
namespace ShowEditorOnEnter
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
internal DevExpress.XtraGrid.GridControl GridControl1;
internal DevExpress.XtraGrid.Views.Grid.GridView GridView1;
internal DevExpress.XtraGrid.Columns.GridColumn colColumn1;
internal DevExpress.XtraGrid.Columns.GridColumn colColumn2;
internal DevExpress.XtraGrid.Columns.GridColumn colColumn3;
internal DevExpress.XtraEditors.TextEdit TextEdit1;
internal System.Data.DataSet DataSet1;
internal System.Data.DataTable DataTable1;
internal System.Data.DataColumn DataColumn1;
internal System.Data.DataColumn DataColumn2;
internal System.Data.DataColumn DataColumn3;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.GridControl1 = new DevExpress.XtraGrid.GridControl();
this.GridView1 = new DevExpress.XtraGrid.Views.Grid.GridView();
this.colColumn1 = new DevExpress.XtraGrid.Columns.GridColumn();
this.colColumn2 = new DevExpress.XtraGrid.Columns.GridColumn();
this.colColumn3 = new DevExpress.XtraGrid.Columns.GridColumn();
this.TextEdit1 = new DevExpress.XtraEditors.TextEdit();
this.DataSet1 = new System.Data.DataSet();
this.DataTable1 = new System.Data.DataTable();
this.DataColumn1 = new System.Data.DataColumn();
this.DataColumn2 = new System.Data.DataColumn();
this.DataColumn3 = new System.Data.DataColumn();
((System.ComponentModel.ISupportInitialize)(this.GridControl1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.GridView1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.TextEdit1.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.DataSet1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.DataTable1)).BeginInit();
this.SuspendLayout();
//
// GridControl1
//
this.GridControl1.DataSource = this.DataTable1;
//
// GridControl1.EmbeddedNavigator
//
this.GridControl1.EmbeddedNavigator.Name = "";
this.GridControl1.Location = new System.Drawing.Point(8, 40);
this.GridControl1.MainView = this.GridView1;
this.GridControl1.Name = "GridControl1";
this.GridControl1.TabIndex = 3;
this.GridControl1.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {
this.GridView1});
this.GridControl1.Enter += new System.EventHandler(this.GridControl1_Enter);
//
// GridView1
//
this.GridView1.Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] {
this.colColumn1,
this.colColumn2,
this.colColumn3});
this.GridView1.GridControl = this.GridControl1;
this.GridView1.Name = "GridView1";
this.GridView1.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Bottom;
//
// colColumn1
//
this.colColumn1.Caption = "Column1";
this.colColumn1.FieldName = "Column1";
this.colColumn1.Name = "colColumn1";
this.colColumn1.Visible = true;
this.colColumn1.VisibleIndex = 0;
//
// colColumn2
//
this.colColumn2.Caption = "Column2";
this.colColumn2.FieldName = "Column2";
this.colColumn2.Name = "colColumn2";
this.colColumn2.Visible = true;
this.colColumn2.VisibleIndex = 1;
//
// colColumn3
//
this.colColumn3.Caption = "Column3";
this.colColumn3.FieldName = "Column3";
this.colColumn3.Name = "colColumn3";
this.colColumn3.Visible = true;
this.colColumn3.VisibleIndex = 2;
//
// TextEdit1
//
this.TextEdit1.EditValue = "Press Tab to focus the grid and start editing";
this.TextEdit1.Location = new System.Drawing.Point(8, 8);
this.TextEdit1.Name = "TextEdit1";
//
// TextEdit1.Properties
//
this.TextEdit1.Properties.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Default;
this.TextEdit1.Size = new System.Drawing.Size(400, 20);
this.TextEdit1.TabIndex = 2;
//
// DataSet1
//
this.DataSet1.DataSetName = "NewDataSet";
this.DataSet1.Locale = new System.Globalization.CultureInfo("en-US");
this.DataSet1.Tables.AddRange(new System.Data.DataTable[] {
this.DataTable1});
//
// DataTable1
//
this.DataTable1.Columns.AddRange(new System.Data.DataColumn[] {
this.DataColumn1,
this.DataColumn2,
this.DataColumn3});
this.DataTable1.TableName = "Table1";
//
// DataColumn1
//
this.DataColumn1.ColumnName = "Column1";
//
// DataColumn2
//
this.DataColumn2.ColumnName = "Column2";
//
// DataColumn3
//
this.DataColumn3.ColumnName = "Column3";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(416, 250);
this.Controls.Add(this.GridControl1);
this.Controls.Add(this.TextEdit1);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.GridControl1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.GridView1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.TextEdit1.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.DataSet1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.DataTable1)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void GridControl1_Enter(object sender, System.EventArgs e) {
GridControl grid = sender as GridControl;
GridView view = grid.MainView as GridView;
if(view.DataRowCount == 0) {
if(view.FocusedRowHandle == GridControl.InvalidRowHandle)
view.FocusedRowHandle = GridControl.NewItemRowHandle;
BeginInvoke(new MethodInvoker(delegate { view.ShowEditor(); }));
}
}
}
}