RadTextBox Initial Text

2 posts, 0 answers
  1. ali
    ali avatar
    3 posts
    Member since:
    Sep 2011

    Posted 29 Sep 2011 Link to this post

    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
  2. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 03 Oct 2011 Link to this post

    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 >>

  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top