Windows窗体:在VB .NET 2002中初始化组件 [英] Windows Forms: Initialize Component in VB .NET 2002

查看:133
本文介绍了Windows窗体:在VB .NET 2002中初始化组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在我们不应该在Windows窗体的初始化

组件中更改的文档?

例如,以下代码由VB .NET生成:


Me.AutoScaleBaseSize = New System.Drawing.Size(5,13)

Me.ClientSize = New System.Drawing.Size(242,223)

Me.Controls.AddRange(New System.Windows.Forms.Control(){Me.btnGreeting,

Me.txtName,Me.lblInstruction})

Me.Menu = Me.OptionMenu

Me.Name =" frmHello"

Me.Text =" Hello"

Me.ResumeLayout(False)


然后我将代码更改为:


With Me

.AutoScaleBaseSize = New System.Drawing.Size(5,13)

.ClientSize = New System.Drawing.Size(242,223)

.Controls.AddRange(New System。 Windows.Forms.Control()_

{.btnGreeting,.txtName,.lblInstruction})

.Menu = .OptionMenu

.Name =" frmHello"

.Text =&qu ot;你好'

.ResumeLayout(假)

结束


这个改变导致控件在设计师视图中消失,但代码

仍然正常运行。


我在哪里可以找到更多关于我们如何处理初始化代码的信息

组件?

-
http://www.standards.com/; 请参阅Howard Kaikow的网站。

Is there documentation of what we should not change in the Initialize
Component of a Windows form?
For example, the following code was generated by VB .NET:

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(242, 223)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnGreeting,
Me.txtName, Me.lblInstruction})
Me.Menu = Me.OptionMenu
Me.Name = "frmHello"
Me.Text = "Hello"
Me.ResumeLayout(False)

I then changed the code to:

With Me
.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
.ClientSize = New System.Drawing.Size(242, 223)
.Controls.AddRange(New System.Windows.Forms.Control() _
{.btnGreeting, .txtName, .lblInstruction})
.Menu = .OptionMenu
.Name = "frmHello"
.Text = "Hello"
.ResumeLayout(False)
End With

This change caused the controls to vanish in designer view, but the code
still ran correctly.

Where can I find more info on what we can do with code in the Initialize
Component?
--
http://www.standards.com/; See Howard Kaikow''s web site.

推荐答案

" Howard Kaikow" < KA **** @ standards.com> schrieb
"Howard Kaikow" <ka****@standards.com> schrieb

在哪里可以找到更多关于我们如何处理
Initialize Component中的代码的信息?

Where can I find more info on what we can do with code in the
Initialize Component?




您无法在InitializeComponent中执行任何操作。请参阅

程序上方的评论。它说:不要使用代码编辑器进行修改,而是使用

表单设计器。

-

Armin



You can do nothing in InitializeComponent. See the comment above the
procedure. It says: Do NOT use the code editor for modifications, use the
Form designer instead.
--
Armin


我没有修改,只是让代码更有效率。


-
http://www.standards.com/; 请参阅Howard Kaikow的网站。

" Armin Zingler" < AZ ******* @ freenet.de>在消息中写道

news:eS ************* @ TK2MSFTNGP09.phx.gbl ...
I''m not modifying, just making the code more efficient.

--
http://www.standards.com/; See Howard Kaikow''s web site.
"Armin Zingler" <az*******@freenet.de> wrote in message
news:eS*************@TK2MSFTNGP09.phx.gbl...
" Howard Kaikow" < KA **** @ standards.com> schrieb
"Howard Kaikow" <ka****@standards.com> schrieb

我在哪里可以找到更多关于我们如何处理
Initialize Component中代码的信息?

Where can I find more info on what we can do with code in the
Initialize Component?



你可以做什么在InitializeComponent中没有任何内容。请参阅上面的评论
程序。它说:不要使用代码编辑器进行修改,而是使用
表单设计器。

-
Armin



You can do nothing in InitializeComponent. See the comment above the
procedure. It says: Do NOT use the code editor for modifications, use the
Form designer instead.
--
Armin



你好,


" Howard Kaikow" < KA **** @ standards.com> schrieb:
Hello,

"Howard Kaikow" <ka****@standards.com> schrieb:
我不修改,只是让代码更有效率。
I''m not modifying, just making the code more efficient.




如果使用不同的设计师似乎有问题

格式化/编写源代码的规则。一些更改可以手工完成

(删除属性值的赋值等),但在修改之前总是要制作

a副本。


-

Herfried K. Wagner

MVP·VB Classic,VB .NET
http://www.mvps.org/dotnet


这篇关于Windows窗体:在VB .NET 2002中初始化组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆