为什么已经实例化了还要再次实例化呢

解决方案 »

  1.   

    InitializeComponent 里面是进行new.对象不new怎么行呢.
    这之前并没有实例化,只是定义了
      

  2.   

    定义了一个控件<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
    Partial Class UserControl1
        Inherits System.Windows.Forms.UserControl    'UserControl 重写 Dispose,以清理组件列表。
        <System.Diagnostics.DebuggerNonUserCode()> _
        Protected Overrides Sub Dispose(ByVal disposing As Boolean)
            Try
                If disposing AndAlso components IsNot Nothing Then
                    components.Dispose()
                End If
            Finally
                MyBase.Dispose(disposing)
            End Try
        End Sub    'Windows 窗体设计器所必需的
        Private components As System.ComponentModel.IContainer    '注意: 以下过程是 Windows 窗体设计器所必需的
        '可以使用 Windows 窗体设计器修改它。
        '不要使用代码编辑器修改它。
        <System.Diagnostics.DebuggerStepThrough()> _
        Private Sub InitializeComponent()
            components = New System.ComponentModel.Container()
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font        MessageBox.Show("显示消息框")
        End SubEnd Class为什么把这个空间拖入一个form后会显示在InitializeComponent()方法中的message呢,这不说明已经实例化了么,请教
      

  3.   

    这样编译这个form时,这个自定义控件还会再次被实例化么?
    脑子有点乱
      

  4.   

    我猜想啊,设计模式时,拖一个控件进来,实际上调用了一次InitializeComponent