回答編集履歴
3
修正
test
CHANGED
@@ -1,191 +1 @@
|
|
1
1
|
追加するコントロールの数を減らすためにサイズ固定のユーザーコントロールにまとめてから追加してみてください。
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
#追記
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
スクロールを自分で実装する例です。
|
10
|
-
|
11
|
-
実装する場合はフォームではなくコントロールにすべきです。
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
```C#
|
16
|
-
|
17
|
-
using System;
|
18
|
-
|
19
|
-
using System.Collections.Generic;
|
20
|
-
|
21
|
-
using System.Data;
|
22
|
-
|
23
|
-
using System.Linq;
|
24
|
-
|
25
|
-
using System.Windows.Forms;
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
namespace WindowsFormsApp1
|
30
|
-
|
31
|
-
{
|
32
|
-
|
33
|
-
public partial class Form1 : Form
|
34
|
-
|
35
|
-
{
|
36
|
-
|
37
|
-
public Form1()
|
38
|
-
|
39
|
-
{
|
40
|
-
|
41
|
-
Children = Enumerable
|
42
|
-
|
43
|
-
.Range(0, 100000)
|
44
|
-
|
45
|
-
.Select(a => (TextBox)null)
|
46
|
-
|
47
|
-
.ToArray();
|
48
|
-
|
49
|
-
VScrollBar = new VScrollBar()
|
50
|
-
|
51
|
-
{
|
52
|
-
|
53
|
-
Parent = this,
|
54
|
-
|
55
|
-
Top = 0,
|
56
|
-
|
57
|
-
Maximum = Children.Count
|
58
|
-
|
59
|
-
};
|
60
|
-
|
61
|
-
VScrollBar.Scroll += (s, e) =>
|
62
|
-
|
63
|
-
{
|
64
|
-
|
65
|
-
ShowChildren(e.NewValue);
|
66
|
-
|
67
|
-
};
|
68
|
-
|
69
|
-
InitializeComponent();
|
70
|
-
|
71
|
-
ResizeVScrollBar();
|
72
|
-
|
73
|
-
}
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
protected IList<TextBox> Children { get; private set; }
|
78
|
-
|
79
|
-
public VScrollBar VScrollBar { get; private set; }
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
private TextBox GetChild(int index)
|
84
|
-
|
85
|
-
{
|
86
|
-
|
87
|
-
if (Children[index] == null)
|
88
|
-
|
89
|
-
{
|
90
|
-
|
91
|
-
Children[index] = new TextBox()
|
92
|
-
|
93
|
-
{
|
94
|
-
|
95
|
-
Text = index.ToString()
|
96
|
-
|
97
|
-
};
|
98
|
-
|
99
|
-
}
|
100
|
-
|
101
|
-
return Children[index];
|
102
|
-
|
103
|
-
}
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
private void RemoveChildFromScreen(int index)
|
108
|
-
|
109
|
-
{
|
110
|
-
|
111
|
-
if (Children[index] == null) return;
|
112
|
-
|
113
|
-
Children[index].Parent = null;
|
114
|
-
|
115
|
-
}
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
private void ShowChildren(int value)
|
120
|
-
|
121
|
-
{
|
122
|
-
|
123
|
-
for (int i = 0; i < value; i++)
|
124
|
-
|
125
|
-
{
|
126
|
-
|
127
|
-
RemoveChildFromScreen(i);
|
128
|
-
|
129
|
-
}
|
130
|
-
|
131
|
-
int top = 0;
|
132
|
-
|
133
|
-
for (int i = value; i < Children.Count; i++)
|
134
|
-
|
135
|
-
{
|
136
|
-
|
137
|
-
if (top < ClientSize.Height)
|
138
|
-
|
139
|
-
{
|
140
|
-
|
141
|
-
GetChild(i).Top = top;
|
142
|
-
|
143
|
-
GetChild(i).Parent = this;
|
144
|
-
|
145
|
-
top += Children[i].Height + 10;
|
146
|
-
|
147
|
-
}
|
148
|
-
|
149
|
-
else
|
150
|
-
|
151
|
-
{
|
152
|
-
|
153
|
-
RemoveChildFromScreen(i);
|
154
|
-
|
155
|
-
}
|
156
|
-
|
157
|
-
}
|
158
|
-
|
159
|
-
}
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
private void ResizeVScrollBar()
|
164
|
-
|
165
|
-
{
|
166
|
-
|
167
|
-
VScrollBar.Left = ClientSize.Width - VScrollBar.Width;
|
168
|
-
|
169
|
-
VScrollBar.Height = ClientSize.Height;
|
170
|
-
|
171
|
-
ShowChildren(VScrollBar.Value);
|
172
|
-
|
173
|
-
}
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
private void Form1_Resize(object sender, EventArgs e)
|
178
|
-
|
179
|
-
{
|
180
|
-
|
181
|
-
ResizeVScrollBar();
|
182
|
-
|
183
|
-
}
|
184
|
-
|
185
|
-
}
|
186
|
-
|
187
|
-
}
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
```
|
2
修正
test
CHANGED
@@ -124,7 +124,7 @@
|
|
124
124
|
|
125
125
|
{
|
126
126
|
|
127
|
-
|
127
|
+
RemoveChildFromScreen(i);
|
128
128
|
|
129
129
|
}
|
130
130
|
|
1
追記
test
CHANGED
@@ -1 +1,191 @@
|
|
1
1
|
追加するコントロールの数を減らすためにサイズ固定のユーザーコントロールにまとめてから追加してみてください。
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
#追記
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
スクロールを自分で実装する例です。
|
10
|
+
|
11
|
+
実装する場合はフォームではなくコントロールにすべきです。
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
```C#
|
16
|
+
|
17
|
+
using System;
|
18
|
+
|
19
|
+
using System.Collections.Generic;
|
20
|
+
|
21
|
+
using System.Data;
|
22
|
+
|
23
|
+
using System.Linq;
|
24
|
+
|
25
|
+
using System.Windows.Forms;
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
namespace WindowsFormsApp1
|
30
|
+
|
31
|
+
{
|
32
|
+
|
33
|
+
public partial class Form1 : Form
|
34
|
+
|
35
|
+
{
|
36
|
+
|
37
|
+
public Form1()
|
38
|
+
|
39
|
+
{
|
40
|
+
|
41
|
+
Children = Enumerable
|
42
|
+
|
43
|
+
.Range(0, 100000)
|
44
|
+
|
45
|
+
.Select(a => (TextBox)null)
|
46
|
+
|
47
|
+
.ToArray();
|
48
|
+
|
49
|
+
VScrollBar = new VScrollBar()
|
50
|
+
|
51
|
+
{
|
52
|
+
|
53
|
+
Parent = this,
|
54
|
+
|
55
|
+
Top = 0,
|
56
|
+
|
57
|
+
Maximum = Children.Count
|
58
|
+
|
59
|
+
};
|
60
|
+
|
61
|
+
VScrollBar.Scroll += (s, e) =>
|
62
|
+
|
63
|
+
{
|
64
|
+
|
65
|
+
ShowChildren(e.NewValue);
|
66
|
+
|
67
|
+
};
|
68
|
+
|
69
|
+
InitializeComponent();
|
70
|
+
|
71
|
+
ResizeVScrollBar();
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
protected IList<TextBox> Children { get; private set; }
|
78
|
+
|
79
|
+
public VScrollBar VScrollBar { get; private set; }
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
private TextBox GetChild(int index)
|
84
|
+
|
85
|
+
{
|
86
|
+
|
87
|
+
if (Children[index] == null)
|
88
|
+
|
89
|
+
{
|
90
|
+
|
91
|
+
Children[index] = new TextBox()
|
92
|
+
|
93
|
+
{
|
94
|
+
|
95
|
+
Text = index.ToString()
|
96
|
+
|
97
|
+
};
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
return Children[index];
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
private void RemoveChildFromScreen(int index)
|
108
|
+
|
109
|
+
{
|
110
|
+
|
111
|
+
if (Children[index] == null) return;
|
112
|
+
|
113
|
+
Children[index].Parent = null;
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
private void ShowChildren(int value)
|
120
|
+
|
121
|
+
{
|
122
|
+
|
123
|
+
for (int i = 0; i < value; i++)
|
124
|
+
|
125
|
+
{
|
126
|
+
|
127
|
+
GetChild(i).Parent = null;
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
int top = 0;
|
132
|
+
|
133
|
+
for (int i = value; i < Children.Count; i++)
|
134
|
+
|
135
|
+
{
|
136
|
+
|
137
|
+
if (top < ClientSize.Height)
|
138
|
+
|
139
|
+
{
|
140
|
+
|
141
|
+
GetChild(i).Top = top;
|
142
|
+
|
143
|
+
GetChild(i).Parent = this;
|
144
|
+
|
145
|
+
top += Children[i].Height + 10;
|
146
|
+
|
147
|
+
}
|
148
|
+
|
149
|
+
else
|
150
|
+
|
151
|
+
{
|
152
|
+
|
153
|
+
RemoveChildFromScreen(i);
|
154
|
+
|
155
|
+
}
|
156
|
+
|
157
|
+
}
|
158
|
+
|
159
|
+
}
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
private void ResizeVScrollBar()
|
164
|
+
|
165
|
+
{
|
166
|
+
|
167
|
+
VScrollBar.Left = ClientSize.Width - VScrollBar.Width;
|
168
|
+
|
169
|
+
VScrollBar.Height = ClientSize.Height;
|
170
|
+
|
171
|
+
ShowChildren(VScrollBar.Value);
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
private void Form1_Resize(object sender, EventArgs e)
|
178
|
+
|
179
|
+
{
|
180
|
+
|
181
|
+
ResizeVScrollBar();
|
182
|
+
|
183
|
+
}
|
184
|
+
|
185
|
+
}
|
186
|
+
|
187
|
+
}
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
```
|