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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem when setting text class properties.

Status
Not open for further replies.

bernardmanning

Programmer
Oct 14, 2003
61
GB
Hi, I';m trying to create a series of controls that will act as my base controls in my application, to give a consistant look and feel.

I've created my base command button as below :-

Code:
Public Class BaseTextBox
    Inherits System.Windows.Forms.TextBox

    Sub New()
        Me.Width = 75
        Me.BorderStyle = BorderStyle.Fixed3D
        Me.BackColor = Color.PowderBlue
        Me.Text = "SomeDefaultText"
    End Sub
End Class

When I drag this onto one of my forms it works great, all the properties get set correctly apart from the Text property.

The text property always defaults to BaseTextBox1, BaseTextBox2 etc.

Does anybody know why this doesn't work?

Many Thanks, Bernard
 
Hi, Got it working...

Code:
Public Class BaseTextBox
    Inherits System.Windows.Forms.TextBox

    Sub New()
        Me.Width = 75
        Me.BorderStyle = BorderStyle.Fixed3D
        Me.BackColor = Color.PowderBlue
        Me.Text = "SomeDefaultText"
    End Sub

   Protected Overrides Sub CreateHandle()
       Me.Text = ""
       MyBase.CreateHandle()
   End Sub 

End Class
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top