C:运行时与预加载

发布于 2024-09-24 14:19:56 字数 551 浏览 1 评论 0原文

我不确定我是否在这里理解了我的术语,但我想知道:

在运行时创建对象是否比在运行之前将对象添加到表单更快?

万一我的术语搞砸了,在加载函数中,您添加以下内容:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

零度° 2024-10-01 14:19:56

如果使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文