Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Adding New Member to TextBox

Hi EveryBody:

How can I add Sub or Function or property to be a member of TextBox ?

For example TextBox1.Text , text is a property in Textbox1 How Can I add the following sub to be a member of textbox1:

Public Sub SaveHtml(ByVal stream As Stream)
If stream Is Nothing Then
Throw New ArgumentNullException("SaveHtml : Must specify a non-null stream to which to save")
End If
Dim content As String = SaveHtml()
Dim writer As New StreamWriter(stream, Encoding.UTF8)
writer.Write(content)
writer.Flush()
End Sub 'SaveHtml

Any Help or redirection will be appreciated

regard's

Husam
[736 byte] By [HusamMc] at [2007-11-11 8:08:51]
# 1 Re: Adding New Member to TextBox
Create a new class that inherits from TextBox and add the desired method to that class:

Public Class MyHTMLTextBox
Inherits System.Windows.Forms.TextBox

Public Sub SaveHtml(ByVal stream As Stream)
' etc.
End Sub
End Class

Now use MyHTMLTextBox on your form instead of a standard TextBox.
Phil Weber at 2007-11-11 21:47:55 >