RadLabel to mimic RadTextBox look

2 posts, 0 answers
  1. John
    John avatar
    14 posts
    Member since:
    Feb 2012

    Posted 20 Feb 2012 Link to this post

    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?

  2. Ivan Petrov
    Ivan Petrov avatar
    701 posts

    Posted 23 Feb 2012 Link to this post

    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.

    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 >>
  3. DevCraft R3 2016 release webinar banner
Back to Top