在我的软件类(class)中,每次提交作业时,我们都必须在表单中包含一个包含每个对象的起始属性的文档。
例如
TextBox1
Location: 241, 115
Name: TextBox1
Size: 100, 20
TabIndex: 0
滚动属性查看器并复制并粘贴表单上 30 多个对象的每个自定义值真的很痛苦...我想知道是否有一段简单的代码或方法可以获取(在至少部分)自动打印输出/查看对象的所有属性。
是否正在考虑某种私有(private)子程序,我可以将其放入程序底部并在加载时运行,获取所有对象,并将非默认属性输出到报告或其他内容?基本上我有什么想法可以做到这一点吗?
任何帮助都会很棒!
最佳答案
为什么不看看 InitializeComponent
方法,您应该能够从那里剪切和粘贴您需要的内容。
Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button()
Me.Label1 = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(0, 0)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(75, 23)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Button1"
Me.Button1.UseVisualStyleBackColor = True
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(12, 46)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(51, 17)
Me.Label1.TabIndex = 1
Me.Label1.Text = "Label1"
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 16.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(282, 255)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
关于vb.net - Winforms 形式 vb.net 中对象的起始属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10973801/