LaBoss
New member
- Joined
- Nov 2, 2010
- Messages
- 2
- Programming Experience
- Beginner
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 (dim txt). the class to this:
I have no idea how and what I do to access this property through the form ... I am calling the class this way:
Someone help me? Grateful for the help ..
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 (dim txt). the class to this:
VB.NET:
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:
VB.NET:
Dim CaixaNIF As New ToolStripTextBoxWithLabel("NIF: ")
AddHandler CaixaCliente.TextoAlterado, AddressOf TextoAlteradoCliente
Someone help me? Grateful for the help ..