我在表单上有一个大约 100 组控件(标签、复选框、文本框)的列表。它们都被标记为默认名称,(textbox1, textbox2, ... textbox101) 它们通常是隐藏的,除非需要。当我运行时:
string msg = "";
foreach (Control child in Controls)
msg = msg + child.Name + ", ";
MessageBox.Show(msg);
只有前 90 个出现在 Controls 集合中(如 Messagebox 输出所示)。就好像我达到了表格的限制,但我知道我没有。
它们都是在 .Designer.cs 文件中创建的,它们看起来都一样。它们的创建方式相同。
...
private System.Windows.Forms.CheckBox checkBox88;
private System.Windows.Forms.Label label88;
private System.Windows.Forms.TextBox textBox88;
private System.Windows.Forms.CheckBox checkBox89;
private System.Windows.Forms.Label label89;
private System.Windows.Forms.TextBox textBox89;
private System.Windows.Forms.CheckBox checkBox90;
private System.Windows.Forms.Label label90;
private System.Windows.Forms.TextBox textBox90;
private System.Windows.Forms.CheckBox checkBox91;
private System.Windows.Forms.Label label91;
private System.Windows.Forms.TextBox textBox91;
private System.Windows.Forms.CheckBox checkBox92;
private System.Windows.Forms.Label label92;
private System.Windows.Forms.TextBox textBox92;
private System.Windows.Forms.CheckBox checkBox93;
private System.Windows.Forms.Label label93;
private System.Windows.Forms.TextBox textBox93;
...
是否有一些底层位置 C# 保存有关表单上的控件的信息?谢谢你!