Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing the (Name) property at Design time

Status
Not open for further replies.

SBendBuckeye

Programmer
May 22, 2002
2,166
US
Hello all,

I am wrapping an extended class in a component so that I can have a Design time presence. At Design time, how do I access the Component (Name) property (eg MyComponent1)? My extended class exposes a Name property which I want to set to the Component (Name) property when I instantiate my extended class in the Component constructor.
Code:
Public Class MyExtendedClass
    Inherits ThirdPartyControl

Public Sub New()
    MyBase.New
End Sub 'New

Public Sub New(ByVal name As String)
    MyClass.New
    Me.Name = name
End Sub 'New

Private m_Name As String = Nothing
Public Property Name As String
    Get
        Return m_Name
    End Get
    Set(ByVal value As String)
        m_Name = value
    End Set
End Property 'Name
Code:
Public Class MyComponent
    Inherits System.ComponentModel.Component

Public Sub New
    MyBase.New
    ' I want to call with my component name (eg MyComponent1).
    m_MyExtendedClass = New MyExtendedClass(Me.(Name))
End Sub 'New

Private m_MyExtendedClass As MyExtendedClass
Public Property MyExtendedClass As MyExtendedClass
    Get
        Return m_MyExtendedClass
    End Get
    Set(ByVal value As MyExtendedClass)
        m_MyExtendedClass = value
    End Set
End Property 'MyExtendedClass
Thanks in advance for any ideas and/or suggestions!
 
It appears that you are trying to create a new instance of MyExtendedClass using the overloaded contstructor. However, when calling the constructor you are referencing a property which is actually set in that constructor's implementation. So passing that value in as a parameter is going to result in a null (nothing). If you want to give the name property a default value then you can reference it that way.

-Kevin

Kevin Davie
Consultant
Sogeti USA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top