C:运行时与预加载
我不确定我是否在这里理解了我的术语,但我想知道:
在运行时创建对象是否比在运行之前将对象添加到表单更快?
万一我的术语搞砸了,在加载函数中,您添加以下内容:
lOptions.AutoSize = true;
lOptions.Location = new System.Drawing.Point(7, 75);
lOptions.Name = "lOptions";
lOptions.Size = new System.Drawing.Size(117, 13);
lOptions.TabIndex = 17;
lOptions.Text = "text";
lOptions.Click += new System.EventHandler(this.lOptions_Click);
gbModify.Controls.Add(lOptions);
我听说它是面向对象工作的一部分。我当然不是要求你告诉我什么是面向对象,但我只是想知道哪种方法更好。
我想如果您只需要创建 3 个标签,那不会有太大区别,但目前我必须创建大约 30 个标签和 30 个组合框。
I'm not sure if I got my terms straight here, but I was wondering:
Is creating objects in run-time faster than adding objects to a form before running it?
In case my terms are messed up, in the load function, you add this:
lOptions.AutoSize = true;
lOptions.Location = new System.Drawing.Point(7, 75);
lOptions.Name = "lOptions";
lOptions.Size = new System.Drawing.Size(117, 13);
lOptions.TabIndex = 17;
lOptions.Text = "text";
lOptions.Click += new System.EventHandler(this.lOptions_Click);
gbModify.Controls.Add(lOptions);
I heard it's part of working Object-Oriented. I'm not asking you to tell me what Object-Oriented is ofcourse, but I was just wondering which method is better.
I guess it wont make much of a difference if you only have 3 labels to create, but at the moment I have to create about 30 labels and 30 comboboxes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果使用 WinForms 设计器添加控件,设计器将在 Form1.Designer.cs 文件中创建代码。
所以速度上完全没有区别。
If you add a Control with the WinForms designer, the designer creates code in your Form1.Designer.cs files.
So there is absolutely no difference in speed.