2 posts, 0 answers
  1. Noel Stieglitz
    Noel Stieglitz avatar
    1 posts
    Member since:
    Jan 2008

    Posted 25 Mar 2008 Link to this post


    I am setting the BackColor of a RadTextBox control at runtime.  There are some discrepancies between what the documentation says, what the recommended approach is in the forums, and what actually seems to work.

    The documentation:


    The fourms:

    What actually works:

    myTextbox.TextBoxElement.TextBoxItem.BackColor =


  2. Martin Vasilev
    Martin Vasilev avatar
    1061 posts

    Posted 28 Mar 2008 Link to this post

    Hi Noel Stieglitz,

    Thank you for writing.

    In general, the mentioned approaches actually illustrate a different way in which you could customize our controls. There is no contradiction. You could choose one, depending on the level of detail you want to set.

    1.     You could change basic properties using the property grid at design-time, or accessing them at run-time programmatically. It depends on the control implementation and its current theme how this property will be taken into account. In your case, you could use the code provided below:

    this.radTextBox1.BackColor = Color.Green; 

    2.     Sometimes, you may need to modify a property of a particular element in the hierarchy (the hierarchy can be shown at design time using the option "Edit UI elements" in the ActionList). The forum’s topic gave information how to change the Background color of the FillPrimitive element of RadButtonControl. Actually, your example code is doing the same. However, there is a difference in changing background of RadTextBox. You should change the BackColor property of the RadTextBoxElement instead of the FillPrimitive Color:

    this.radTextBox1.TextBoxElement.TextBoxItem.BackColor = Color.Green; 

    The code below is equivalent to the one above:

    ((RadTextBoxItem)this.radTextBox2.TextBoxElement.GetChildrenByType(typeof(RadTextBoxItem))[0]).BackColor = Color.Green; 

    3.     Using custom themes made with Telerik Visual Style Builder. This is the most advanced way to customize the appearance of the controls. In the themes, you can create different property sets for different conditions (like IsMouseOver, IsFocused, etc.). In addition, the text can be set in a theme for advanced effects in different states. We decided to allow setting as many properties as possible by a theme in order to allow a greter degree of freedom. You could learn more about using the Visual Style Builder in our video section.

    I hope this was helpful. If you have other questions do not hesitate to contact me again.

    Martin Vasilev
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top