【问题标题】:Starting properties of objects in Winforms form vb.netWinforms窗体vb.net中对象的起始属性
【发布时间】:2012-06-13 23:39:53
【问题描述】:

在我的软件课程中,每次提交作业时,我们都必须在表单中包含一个文档,其中包含每个对象的起始属性。

例如

TextBox1
Location: 241, 115
Name: TextBox1
Size: 100, 20
TabIndex: 0

滚动属性查看器并复制并粘贴表单上 30 多个对象的每个自定义值真的很痛苦...我想知道是否有一段简单的代码或获取 (at至少部分)自动打印输出/查看对象的所有属性。

是否正在考虑某种私有子,我可以进入程序底部并在加载时运行,获取所有对象,并将非默认属性输出到报告或其他东西?基本上有关于我如何做到这一点的想法吗?

任何帮助都会很棒!

【问题讨论】:

    标签: vb.net winforms properties form-designer


    【解决方案1】:

    为什么不看看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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-25
      • 2018-05-21
      • 2015-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-11
      相关资源
      最近更新 更多