VSB - Background color for ReadOnly Property

3 posts, 1 answers
  1. Gone2TheDogs
    Gone2TheDogs avatar
    22 posts
    Member since:
    May 2016

    Posted 04 Nov Link to this post

    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. Answer
    Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 04 Nov Link to this post

    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 handle 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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Gone2TheDogs
    Gone2TheDogs avatar
    22 posts
    Member since:
    May 2016

    Posted 04 Nov in reply to Dimitar Link to this post

    Thanks, Dimitar for the prompt response!

     

Back to Top