User Control Events

G

Guest

I have a user control and it has a textbox. I added it to form. But i can't use the textbox's events on form. How can i do it? Pls help me.
 
K

Ken Tucker [MVP]

Hi,

You will have to raise the events your self when the textchanges.
Here is a simple example.

Public Class UserControl1

Inherits System.Windows.Forms.UserControl

#Region " Windows Form Designer generated code "



Public Shadows Event TextChanged(ByVal sender As Object, ByVal e As
EventArgs)

Public Shadows Property Text() As String

Get

Return TextBox1.Text

End Get

Set(ByVal Value As String)

TextBox1.Text = Value

End Set

End Property

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox1.TextChanged

RaiseEvent TextChanged(Me, e)

End Sub

End Class



Ken

----------------

Erencan said:
I have a user control and it has a textbox. I added it to form. But i
can't use the textbox's events on form. How can i do it? Pls help me.
 
W

WStoreyII

what does the shadow Term do ken?

WSToreyII

Ken Tucker said:
Hi,

You will have to raise the events your self when the textchanges.
Here is a simple example.

Public Class UserControl1

Inherits System.Windows.Forms.UserControl

#Region " Windows Form Designer generated code "



Public Shadows Event TextChanged(ByVal sender As Object, ByVal e As
EventArgs)

Public Shadows Property Text() As String

Get

Return TextBox1.Text

End Get

Set(ByVal Value As String)

TextBox1.Text = Value

End Set

End Property

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox1.TextChanged

RaiseEvent TextChanged(Me, e)

End Sub

End Class



Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top