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

TextBox Style

1 Answer 113 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
zeng dongmei
Top achievements
Rank 1
zeng dongmei asked on 13 May 2010, 08:31 AM
Hi,
   The TextBox's backcolor is the same no matter it's in editor state or readonly state, and i can't tell it's state from it's appreance.
I want it's backcolor changes when it turns to readonly state. Is there any easy way to do this?

Looking forward to your replay.

BRS
 zeng

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 19 May 2010, 04:08 PM
Hi zeng dongmei,

The easiest approach for your scenario is to use an extended RadTextBox:
public class MyTextBox : RadTextBox
{
    protected override void OnReadOnlyChanged(EventArgs e)
    {
        base.OnReadOnlyChanged(e);
  
        if (this.ReadOnly)
        {
            SetColor(Color.Red);
        }
        else
        {
            SetColor(Color.Green);
        }
    }
  
    private void SetColor(Color color)
    {
        this.TextBoxElement.BackColor = color;
        this.TextBoxElement.Fill.BackColor = color;
        this.TextBoxElement.Border.ForeColor = color;
    }
  
    public override string ThemeClassName
    {
        get
        {
            return typeof(RadTextBox).FullName;
        }
    }
}


Best wishes,
Nikolay
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
TextBox
Asked by
zeng dongmei
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or