Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating an empty date textbox

Status
Not open for further replies.

protechdm

Programmer
Dec 30, 2001
36
GB
This is baffling me!!

I have created the following class :-

Public Class DateTextBox
Inherits System.Windows.Forms.TextBox
Private strTempText As String = " / / "
Public Sub New()
MyBase.New()
End Sub

<DefaultValue(&quot; / / &quot;)> Public Overrides Property Text() As String
Get
Return strTempText
End Get
Set(ByVal Value As String)
strTempText = Value
End Set

End Property



So, when I add the control into my toolbox I can place any date related textbox on to the form and not have to mess around with it at all. But it does not appear to work! For a start, the text property automatically gets filled with &quot;DateTextBox1&quot; and then when you reset the property to its default it displays correctly in the properties window as &quot; / / &quot; but the control itself is blank. Then, if you run the form the textbox is still blank.

Many thanks.

Glyn.
 
You still need the base class to display the data. I have not tried extending a control and do not know about the default value but I would start as follows.

Public Class DateTextBox
Inherits System.Windows.Forms.TextBox
Public Sub New()
MyBase.New()
End Sub

<DefaultValue(&quot; / / &quot;)> Public Overrides Property Text() As String
Get
Return Mybase.text
End Get
Set(ByVal Value As String)
Mybase.text = Value
End Set

End Property



Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top