LaBoss 0 Newbie Poster

Good afternoon,

I'm having some trouble with a class that uses the ToolStripControlHost, I have to create a label and a label beside the textbox, this works, the problem now and I can not access the property. Text of textbox (txt). the class to this:

Public Class ToolStripTextBoxWithLabel
  Inherits ToolStripControlHost

  Public Event TextoAlterado(ByVal sender As System.Object, ByVal e As System.EventArgs)

  Public Sub New(Optional ByVal lblText As String = "label")

    MyBase.New(New ControlPanel(lblText))
    AddHandler CType(MyBase.Control, ControlPanel).TextoAlterado, AddressOf InformaTextoAlterado

  End Sub

  Public Sub InformaTextoAlterado(ByVal sender As Object, ByVal e As System.EventArgs)
    RaiseEvent TextoAlterado(sender, e)
  End Sub

  Public ReadOnly Property ControlPanelControl() As ControlPanel
    Get
      Return CType(Me.Control, ControlPanel)
    End Get
  End Property

End Class


Public Class ControlPanel
  Inherits Panel

  Friend WithEvents txt As New TextBox
  Friend WithEvents lbl As New Label

  Public Event TextoAlterado(ByVal sender As System.Object, ByVal e As System.EventArgs)
  Private Sub txt_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt.TextChanged
    RaiseEvent TextoAlterado(sender, e)
  End Sub

  Public Sub New(ByVal lblText As String)

    Me.Height = 20

    lbl.Anchor = AnchorStyles.Left Or AnchorStyles.Top Or AnchorStyles.Bottom
    lbl.Text = lblText
    lbl.TextAlign = ContentAlignment.BottomLeft
    lbl.AutoSize = True
    lbl.Height = Me.Height
    lbl.Location = New Point(0, 3)
    lbl.Parent = Me

    txt.Anchor = AnchorStyles.Left Or AnchorStyles.Right Or AnchorStyles.Top
    txt.Location = New Point(lbl.Right + 5, 0)
    txt.Width = Me.Width - txt.Left

    txt.Parent = Me

  End Sub
End Class

I have no idea how and what I do to access this property through the form ... I am calling the class this way:

Dim CaixaNIF As New ToolStripTextBoxWithLabel("NIF: ")

    AddHandler CaixaCliente.TextoAlterado, AddressOf TextoAlteradoCliente

Someone help me? Grateful for the help ..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.