Gray Backcolor in Inherited Textbox

7 posts, 3 answers
  1. Eastern
    Eastern avatar
    43 posts
    Member since:
    Sep 2010

    Posted 09 Nov 2010 Link to this post

    hello,

    i make a user control and inherit it from RadTextBox , the problem is backcolor of my user control is gray instead of white.
    i tried to change it via various methods ,but nothing worked till.

    how can i solve this problem ?
  2. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 09 Nov 2010 Link to this post

    Hello Eastern,

    To set the back color, you just need to get to the TextBoxElement. Please consider the following code:

    Me.RadTextBox1.TextBoxElement.BackColor = Color.White

    hope that helps
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Eastern
    Eastern avatar
    43 posts
    Member since:
    Sep 2010

    Posted 09 Nov 2010 Link to this post

    may i ask how can i change the border color of textbox in this inherited user control ?
    default border color is somehow blue , i want to change it to red without messing with themes.

    how can i do that ?
  5. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 09 Nov 2010 Link to this post

    Hi Eastern,

    You can set the border color in this way..
    DirectCast(Me.RadTextBox1.TextBoxElement.Children(2), Telerik.WinControls.Primitives.BorderPrimitive).ForeColor = Color.Black


    You can view the element tree by using the smart tag and "Edit UI Elements"

    Hope that helps
    Richard
  6. Eastern
    Eastern avatar
    43 posts
    Member since:
    Sep 2010

    Posted 09 Nov 2010 Link to this post

    just another question ,

    is there anyway that i can change only the bottom borderline color ?
  7. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 09 Nov 2010 Link to this post

    Hi Eastern,

    I may be wrong, but as the border is being painted using the forecolor, it doesn't seem to behave as a normal border. I've found a workaround, though it's not ideal as it leaves a little of the border showing at the sides. Have a look at trying:

    DirectCast(Me.RadTextBox1.TextBoxElement.Children(2), Telerik.WinControls.Primitives.BorderPrimitive).ForeColor = Color.Black
    DirectCast(Me.RadTextBox1.TextBoxElement.Children(2), Telerik.WinControls.Primitives.BorderPrimitive).GradientStyle = Telerik.WinControls.GradientStyles.Linear

    Let me know if that helps
    Richard
  8. Eastern
    Eastern avatar
    43 posts
    Member since:
    Sep 2010

    Posted 09 Nov 2010 Link to this post

    Yeah, thanks man,
    that was definitely what i was looking for ;)
Back to Top
UI for WinForms is Visual Studio 2017 Ready