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

RadLabel to mimic RadTextBox look

1 Answer 95 Views
Themes and Visual Style Builder
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 20 Feb 2012, 11:08 PM
I want to make a RadLabel look like a RadTextBox in the current theme, but I have not been able to figure out how to fully accomplish this.

I need to display read-only data on a dialog, but using the RadTextBox and setting ReadOnly to true does not give the behavior I want.  The control is still selectable,  it takes focus and tab, and the text is still selectable.  Even if I set Focusable=false and TabStop=false it behaves the same.  If I set Enabled=false the behavior seems correct, but the control becomes grayed out which is not how I want it to look.

If I use a RadLabel to show this data it behaves correctly: it does not accept focus and does not let the user select text in it.  If I set the BackColor to like "White" it looks close to how I want it to look, but if I do this it no longer follows the theme.  What I want to do is something like set BackColor to whatever the BackColor of a RadTextBox would be in the current theme, but it does not look like themes are applied in this way. 

So, is there a way to ask the current theme what the BackColor of a RadTextBox should be?  Is there some other way to accomplish this?

Thanks

1 Answer, 1 is accepted

Sort by
0
Ivan Petrov
Telerik team
answered on 23 Feb 2012, 12:55 PM
Hello John,

Thank you for writing.

There are several things you can do in this case. You can either create custom theme(s) for the RadLabel or you can do it only with code. The first option is recommended as it will allow you to change the look of the labels easier. The second option would only work if you have a visible RadTextBox even for a moment as themes are applied only to visible controls after they have been created. You can then take the theme info and apply it to the RadLabel. I have attached a sample project which demonstrates this.

I hope you will find this useful. If you have further questions, I would be glad to help.

Regards,
Ivan Petrov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
Themes and Visual Style Builder
Asked by
John
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Share this question
or