This is a migrated thread and some comments may be shown as answers.

RadTextBox Initial Text

1 Answer 74 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
ali
Top achievements
Rank 1
ali asked on 29 Sep 2011, 04:56 PM
Hello all,

I have a custom radtextbox class called PosNegTB. Now i want to set the inital text value of that class to "0.00", this is the code i have for it:

public sub new
mybase.new
mybase.text = "0.00"

end sub

but when i add this class onto my main form the text inside it is "PosNegTB". What am i doing wrong? Plz help.


Thank you in advance

1 Answer, 1 is accepted

Sort by
0
Ivan Petrov
Telerik team
answered on 03 Oct 2011, 01:00 PM
Hi Ali,

Thank you for writing.

As easy as it might seem this task is not so simple. You cannot change the default value of a property in a class that inherits from its owner. One solution for your task is to override the Text property and check whether the Site property is null and set the property only then. This means setting the property only when you are not at design time. This will allow you to set the property in the constructor but will prevent you from setting it at design time. If this is not a problem for you, here is the code for the property:

Public Overrides Property Text As String
  Get
    Return MyBase.Text
  End Get
  Set(value As String)
    If Site Is Nothing Then MyBase.Text = value
  End Set
End Property

I hope this will help you. Should you have further questions, I would be glad to help. Greetings,
Ivan Petrov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
TextBox
Asked by
ali
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Share this question
or