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

VSB - Background color for ReadOnly Property

2 Answers 374 Views
Tools - VSB, Control Spy, Shape Editor
This is a migrated thread and some comments may be shown as answers.
Gone2TheDogs
Top achievements
Rank 2
Iron
Veteran
Gone2TheDogs asked on 04 Nov 2016, 11:07 AM

I need to change the background color for input type controls (Textbox, etc...) when their property for ReadOnly is equal to True. Currently, it stays white and the font is bold. I'm new to VSB. I watched the videos and looked through the documentation, but I didn't see how to set the background color based on a control's ReadOnly property state. Is this possible? and if so, how is this done in VSB?

 

Thanks!

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 04 Nov 2016, 12:02 PM
Hello Bob,

You can set the styles only for the predefined states and there is no state for the read-only mode. In this case, you can create a custom control that inherits RadTextBox and this there:
class MyTextBox : RadTextBox
{
   public MyTextBox()
    {
        this.ReadOnlyChanged += MyTextBox_ReadOnlyChanged;
    }
 
    private void MyTextBox_ReadOnlyChanged(object sender, EventArgs e)
    {
        if (this.ReadOnly)
        {
            this.BackColor = Color.Green;
        }
        else
        {
            this.BackColor = Color.White;
        }
    }
}

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
Gone2TheDogs
Top achievements
Rank 2
Iron
Veteran
answered on 04 Nov 2016, 12:48 PM

Thanks, Dimitar for the prompt response!

 

Tags
Tools - VSB, Control Spy, Shape Editor
Asked by
Gone2TheDogs
Top achievements
Rank 2
Iron
Veteran
Answers by
Dimitar
Telerik team
Gone2TheDogs
Top achievements
Rank 2
Iron
Veteran
Share this question
or