回答編集履歴
1
コード修正
test
CHANGED
@@ -20,25 +20,17 @@
|
|
20
20
|
|
21
21
|
|
22
22
|
|
23
|
-
'
|
23
|
+
'グリッドの定義
|
24
24
|
|
25
25
|
DataGridView1.ColumnCount = 2
|
26
26
|
|
27
|
-
DataGridView1.
|
27
|
+
DataGridView1.Columns(0).HeaderText = "名前"
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
|
31
|
-
DataGridView1(0
|
29
|
+
DataGridView1.Columns(0).Name = "名前"
|
32
|
-
|
30
|
+
|
33
|
-
DataGridView1(1
|
31
|
+
DataGridView1.Columns(1).HeaderText = "個数"
|
34
|
-
|
32
|
+
|
35
|
-
DataGridView1(
|
33
|
+
DataGridView1.Columns(1).Name = "個数"
|
36
|
-
|
37
|
-
DataGridView1(1, 1).Value = 4
|
38
|
-
|
39
|
-
DataGridView1(0, 2).Value = "ccc"
|
40
|
-
|
41
|
-
DataGridView1(1, 2).Value = 5
|
42
34
|
|
43
35
|
|
44
36
|
|
@@ -80,33 +72,17 @@
|
|
80
72
|
|
81
73
|
'★★★データの追加★★★
|
82
74
|
|
75
|
+
For i = 0 To DataGridView1.Rows.Count - 2
|
76
|
+
|
83
|
-
dtRow = ds.Tables(0).NewRow
|
77
|
+
dtRow = ds.Tables(0).NewRow
|
84
|
-
|
78
|
+
|
85
|
-
dtRow(0) = DataGridView1(0,
|
79
|
+
dtRow(0) = DataGridView1(0, i).Value
|
86
|
-
|
80
|
+
|
87
|
-
dtRow(1) = DataGridView1(1,
|
81
|
+
dtRow(1) = DataGridView1(1, i).Value
|
88
|
-
|
82
|
+
|
89
|
-
ds.Tables(0).Rows.Add(dtRow)
|
83
|
+
ds.Tables(0).Rows.Add(dtRow)
|
90
|
-
|
91
|
-
|
92
|
-
|
84
|
+
|
93
|
-
|
85
|
+
Next
|
94
|
-
|
95
|
-
dtRow(0) = DataGridView1(0, 1).Value
|
96
|
-
|
97
|
-
dtRow(1) = DataGridView1(1, 1).Value
|
98
|
-
|
99
|
-
ds.Tables(0).Rows.Add(dtRow)
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
dtRow = ds.Tables(0).NewRow
|
104
|
-
|
105
|
-
dtRow(0) = DataGridView1(0, 2).Value
|
106
|
-
|
107
|
-
dtRow(1) = DataGridView1(1, 2).Value
|
108
|
-
|
109
|
-
ds.Tables(0).Rows.Add(dtRow)
|
110
86
|
|
111
87
|
|
112
88
|
|
@@ -142,6 +118,8 @@
|
|
142
118
|
|
143
119
|
'Chartコントロールにタイトルを設定
|
144
120
|
|
121
|
+
Chart1.Titles.Clear()
|
122
|
+
|
145
123
|
Chart1.Titles.Add("アクセス数とユニークユーザー数")
|
146
124
|
|
147
125
|
|
@@ -204,6 +182,58 @@
|
|
204
182
|
|
205
183
|
|
206
184
|
|
185
|
+
Private Sub DataGridView1_EditingControlShowing(sender As Object, e As DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing
|
186
|
+
|
187
|
+
'表示されているコントロールがDataGridViewTextBoxEditingControlか調べる
|
188
|
+
|
189
|
+
If TypeOf e.Control Is DataGridViewTextBoxEditingControl Then
|
190
|
+
|
191
|
+
Dim dgv As DataGridView = CType(sender, DataGridView)
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
'編集のために表示されているコントロールを取得
|
196
|
+
|
197
|
+
Dim tb As DataGridViewTextBoxEditingControl =
|
198
|
+
|
199
|
+
CType(e.Control, DataGridViewTextBoxEditingControl)
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
'イベントハンドラを削除
|
204
|
+
|
205
|
+
RemoveHandler tb.KeyPress, AddressOf DataGridView1_KeyPress
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
'該当する列か調べる
|
210
|
+
|
211
|
+
If dgv.CurrentCell.OwningColumn.Name = "個数" Then
|
212
|
+
|
213
|
+
'KeyPressイベントハンドラを追加
|
214
|
+
|
215
|
+
AddHandler tb.KeyPress, AddressOf DataGridView1_KeyPress
|
216
|
+
|
217
|
+
End If
|
218
|
+
|
219
|
+
End If
|
220
|
+
|
221
|
+
End Sub
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
Private Sub DataGridView1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles DataGridView1.KeyPress
|
226
|
+
|
227
|
+
'数字しか入力できないようにする
|
228
|
+
|
229
|
+
If e.KeyChar < "0"c Or e.KeyChar > "9"c Then
|
230
|
+
|
231
|
+
e.Handled = True
|
232
|
+
|
233
|
+
End If
|
234
|
+
|
235
|
+
End Sub
|
236
|
+
|
207
237
|
End Class
|
208
238
|
|
209
239
|
```
|