Imports System.ComponentModel

Namespace ComponentModel
    <ToolboxItem(False)> _
        Public Class LabelTextBox
        Inherits System.Windows.Forms.UserControl
        Implements IEditorControl

#Region " Windows Form Designer generated code "

        Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                If Not (components Is Nothing) Then
                    components.Dispose()
                End If
            End If
            MyBase.Dispose(disposing)
        End Sub

        'Required by the Windows Form Designer
        Private components As System.ComponentModel.IContainer

        'NOTE: The following procedure is required by the Windows Form Designer
        'It can be modified using the Windows Form Designer.  
        'Do not modify it using the code editor.
        Friend WithEvents Label As System.Windows.Forms.Label
        Friend WithEvents TextBox As System.Windows.Forms.TextBox
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
            Me.Label = New System.Windows.Forms.Label
            Me.TextBox = New System.Windows.Forms.TextBox
            Me.SuspendLayout()
            '
            'Label
            '
            Me.Label.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                        Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
            Me.Label.Location = New System.Drawing.Point(0, 0)
            Me.Label.Name = "Label"
            Me.Label.Size = New System.Drawing.Size(200, 16)
            Me.Label.TabIndex = 0
            '
            'TextBox
            '
            Me.TextBox.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                        Or System.Windows.Forms.AnchorStyles.Left) _
                        Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
            Me.TextBox.Location = New System.Drawing.Point(0, 16)
            Me.TextBox.Name = "TextBox"
            Me.TextBox.Size = New System.Drawing.Size(200, 20)
            Me.TextBox.TabIndex = 1
            Me.TextBox.Text = ""
            '
            'LabelTextBox
            '
            Me.Controls.Add(Me.TextBox)
            Me.Controls.Add(Me.Label)
            Me.Name = "LabelTextBox"
            Me.Size = New System.Drawing.Size(200, 40)
            Me.ResumeLayout(False)

        End Sub

#End Region

        Private Block As Boolean

        Public Event ValueChanged() Implements IEditorControl.ValueChanged

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

        Public Property Value() As Object Implements IEditorControl.Value
            Get
                Return TextBox.Text
            End Get
            Set(ByVal value As Object)
                Block = True
                TextBox.Text = DirectCast(value, String)
                Block = False
            End Set
        End Property

        Public Overrides Property Text() As String
            Get
                Return Label.Text
            End Get
            Set(ByVal value As String)
                Label.Text = value
            End Set
        End Property

        Private Sub TextBox_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TextBox.TextChanged
            If Not Block Then
                RaiseEvent ValueChanged()
            End If
        End Sub

        Public Shadows Property Height() As Integer
            Get
                Return MyBase.Height
            End Get
            Set(ByVal Value As Integer)
                TextBox.Multiline = True
                TextBox.AcceptsReturn = True
                TextBox.AcceptsTab = True
                MyBase.Height = Value
            End Set
        End Property
    End Class
End Namespace