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

BackColor

1 Answer 105 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Noel Stieglitz
Top achievements
Rank 1
Noel Stieglitz asked on 25 Mar 2008, 08:20 PM
Hi,

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:

ms-help://telerik.winforms.5.0/telerik.winforms.raduielements/RadTextBoxProgramming.html

The fourms:

http://www.telerik.com/community/forums/thread/b311D-hkggh.aspx



Noel

1 Answer, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 28 Mar 2008, 05:51 PM
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.

Greetings,
Martin Vasilev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
General Discussions
Asked by
Noel Stieglitz
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Share this question
or