RadTextBox BackColor not working?

25 posts, 0 answers
  1. Elizabeth
    Elizabeth avatar
    8 posts
    Member since:
    Sep 2008

    Posted 22 Apr 2009 Link to this post

    Seems simple enough...I set BackColor Property on a RadTextBox to something other than System.Control, and it appears to make no change.  I can set ForeColor and get the desired change.  What am I missing?  We are using RadControls for WinForms Q3 2008.

    Thanks.
  2. David Mills
    David Mills avatar
    2 posts
    Member since:
    Mar 2009

    Posted 23 Apr 2009 Link to this post

    I am having the same problem.
  3. Elizabeth
    Elizabeth avatar
    8 posts
    Member since:
    Sep 2008

    Posted 23 Apr 2009 Link to this post

    Crazy that it takes 5 steps...oh well.

    Thanks for contacting us. In order to change the BackColor of the RadTextBox you should use the Edit UI Elements dialog which you can open from the Smart Tag of the control while at design time.

    Follow these steps in order to achieve the desired appearance:

    1. Drop a RadTextBox control on a Form in Visual Studio.

    2. Select the control and open its Smart Tag.

    3. Open the Edit UI Elements dialog from the Smart Tag.

    4. You see the hierarchy of elements that builds the Telerik RadTextBox control. Select the RadTextBoxItem node from the tree on the left and change its BackColor from the Property Grid on the right.

    5. Select the FillPrimitive element from the tree on the left and change its BackColor property again from the grid on the right. You should note that the GradientStyle property of the FillPrimitive should be set to Solid
  4. David Mills
    David Mills avatar
    2 posts
    Member since:
    Mar 2009

    Posted 23 Apr 2009 Link to this post

    I know...Here are is how I got it to work in VB...


     

    DirectCast(AM_RadTextBox_AM_Process.TextBoxElement.Children(1), FillPrimitive).BackColor = Color.Linen

     

     

    DirectCast(AM_RadTextBox_AM_Process.GetChildAt(0).GetChildAt(0), RadTextBoxItem).BackColor = Color.Linen

     

  5. Deyan
    Admin
    Deyan avatar
    2147 posts

    Posted 24 Apr 2009 Link to this post

    Hello Elizabeth and David,

    Basically, the BackColor property that comes with the RadTextBox control is inherited from the base Control class that is part of the .NET Framework. By setting this property you change the background color of the control that serves as a surface for our RadTextBox to paint itself. As you may know, the Telerik controls are built upon the Telerik Presentation Framework which is very similar to the WPF architecture, i. e. the controls are built from primitives like FillPrimitive, BorderPrimitive, TextPrimitive etc. This enables the more flexible customization of the appearance of our product. The primitive hierarchy of the RadTextBox is painted upon the surface control and thus you cannot see the result of setting the BackColor property. This implementation enables the user to customize the RadTextBox by separately defining border properties, back color properties and text properties (by modifying the corresponding primitives) and thus creating stylish GUIs built from gradients, alpha blending and transformations.

    However, the RadTextBox control is slightly different since it also uses the standard Windows Forms TextBox control, i.e. it wraps its functionality. Therefore, in order to set the background color of the RadTextBox control, you have to separately set the color for the FillPrimitive and the RadTextBoxItem (which is actually the standard text box control) and thus achieving the effect of defining a background color for the whole control. You can do this by using the Element Hierarchy Editor.

    I hope this clarifies the reason why setting the BackColor property will not produce the expected result.

    Regards,
    Deyan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. TwoLaJit
    TwoLaJit avatar
    38 posts
    Member since:
    Nov 2006

    Posted 10 Jun 2009 Link to this post

    This makes sense, I was wondering about this. This confirms it.
  7. Frank
    Frank avatar
    3 posts
    Member since:
    Jul 2011

    Posted 14 Oct 2011 Link to this post

    I've played with this for a while and I cannot set the full background color (or foreground) of a radTextBox using code

    This line below will set an inner border to the indicated color - but I can't figure out the object hierarchy to get to the inner textBox so I can set either the background or foreground color

    radTextBox1.TextBoxElement.Fill.BackColor = Color.Yellow;

    Could you supply a C# sample to change the foreground and background color for a radTextBox
  8. Nikolay
    Admin
    Nikolay avatar
    1805 posts

    Posted 17 Oct 2011 Link to this post

    Hi Frank,

    In order to change the color of the text box part, you should add one more line to the line that you have found:

    this.radTextBox1.TextBoxElement.TextBoxItem.BackColor = Color.Yellow;
    this.radTextBox1.TextBoxElement.TextBoxItem.ForeColor = Color.Red;

    In order to change the color of the border, you have to access the Border object:
    this.radTextBox1.TextBoxElement.Border.ForeColor = Color.Red;

    As to the color of the text, you can changed it as shown below:
    this.radTextBox1.TextBoxElement.TextBoxItem.ForeColor = Color.Red;

    In case you have doubts about the hierarchy of a RadControl, you can use our RadControlSpy tool which will help you in this task.

    I hope this helps.

    Regards,
    Nikolay
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

  9. Frank
    Frank avatar
    3 posts
    Member since:
    Jul 2011

    Posted 17 Oct 2011 Link to this post

    Thanks - and I'll try out radcontrolspy.
  10. Fabian Raul Jofre
    Fabian Raul  Jofre avatar
    29 posts
    Member since:
    Dec 2008

    Posted 10 Apr 2013 Link to this post

    this.radTextBox1.TextBoxElement.Border.ForeColor works only for the external border line, im still having a blank space in the control, even if i set the this.radTextBox1.TextBoxElement.Border.BackColor property.

    Regards!
  11. Stefan
    Admin
    Stefan avatar
    2906 posts

    Posted 16 Apr 2013 Link to this post

    Hi Fabian,

    This would probably be the FillPrimitive of RadTextBoxElement. Here is the code needed to change the backcolor of the control to yellow, the border to red and the text to blue:
    this.radTextBox1.TextBoxElement.Fill.BackColor = Color.Yellow;
    this.radTextBox1.TextBoxElement.TextBoxItem.BackColor = Color.Yellow;
    this.radTextBox1.TextBoxElement.Border.ForeColor = Color.Red;
    this.radTextBox1.TextBoxElement.TextBoxItem.ForeColor = Color.Blue;

    I hope this helps.
     
    Greetings,
    Stefan
    the Telerik team
    WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
  12. Sean
    Sean avatar
    4 posts
    Member since:
    Mar 2012

    Posted 20 Nov 2013 Link to this post

    how you do this same client side(JavaScript)?
  13. Stefan
    Admin
    Stefan avatar
    2906 posts

    Posted 20 Nov 2013 Link to this post

    Hi Sean,

    This forum concerns RadControls for WinForms, while your question seems to be related to RadControls for ASP.NET AJAX. Please address your question in the appropriate forum in order to get adequate assistance: http://www.telerik.com/community/forums/aspnet-ajax.aspx.

    Regards,
    Stefan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  14. Ke
    Ke avatar
    18 posts
    Member since:
    Feb 2016

    Posted 09 Mar 2016 Link to this post

    I still don't understand the differences between fill primitives and textboxitems.backcolor

    They seem to do the same job: set Radcontrol's background color. Why are there both anyway? 

  15. Dess
    Admin
    Dess avatar
    2164 posts

    Posted 10 Mar 2016 Link to this post

    Hello Ke,

    Thank you for writing.

    The Telerik Presentation Framework (TPF) offers WPF-like features within classic Windows Forms applications. Note that a control is built up from a few simple types of elements. By working with these elements, you can customize any control on a very granular level.

    In Q1 2016 SP1 (version 2016.1.216) we introduced some improvements of the Telerik Presentation Framework and now setting the RadTextBox.BackColor will apply the desired color without the necessity to specify the color for the inner elements:
    this.radTextBox1.BackColor = Color.Red;

    I hope this information helps. Should you have further questions I would be glad to help.
     
    Regards,
    Dess
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  16. Eddy Valson
    Eddy Valson avatar
    1 posts
    Member since:
    Feb 2016

    Posted 23 Jan Link to this post

    Here is how to add backcolor to radtextbox server-side, i mean within the tag itself.

     <telerik:RadTextBox ID="txtAudit1" EnabledStyle-BackColor="Black" runat="server" Width="100%" CssClass="text_alignment_right" InputType="Number" ReadOnly="true">

    Use the :  EnabledStyle-BackColor="Black"

    That's it.

  17. Dess
    Admin
    Dess avatar
    2164 posts

    Posted 24 Jan Link to this post

    Hello Eddy Valson,

    Thank you for writing.  

    I would like to note that this forum is relevant for the Telerik UI for WinForms suite. Feel free to post your questions/replies regarding other products in the relevant forum: http://www.telerik.com/forums

    Thank you for your understanding.

    Regards,
    Dess
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  18. Michael
    Michael avatar
    15 posts
    Member since:
    Nov 2014

    Posted 21 Jun in reply to Dess Link to this post

    Hi.  I'm trying to set focus color on a RadTextBoxControl.

    I use radTextBoxControl.TextBoxElement.FocusBorderColor = Color.Red;

    When textbox is clicked into, nothing happens.  Setting BorderColor does work.  Any help?  Thanks.

  19. Dess
    Admin
    Dess avatar
    2164 posts

    Posted 23 Jun Link to this post

    Hello Michael, 

    Thank you for writing.  

    In order to use the TextBoxElement.FocusBorderColor it is necessary to set the EnableFocusBorderproperty to true
    this.radTextBoxControl1.TextBoxElement.FocusBorderColor = Color.Blue;
    this.radTextBoxControl1.TextBoxElement.EnableFocusBorder = true;

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  20. Michael
    Michael avatar
    15 posts
    Member since:
    Nov 2014

    Posted 23 Jun in reply to Dess Link to this post

    That started working but i only get a border on the bottom of the textboxcontrol.  See attached file.
  21. Dess
    Admin
    Dess avatar
    2164 posts

    Posted 27 Jun Link to this post

    Hello Michael, 

    Thank you for writing back. 
     
    Indeed, only a bottom border is displayed as it is demonstrated in the referred help article: http://docs.telerik.com/devtools/winforms/telerik-presentation-framework/focus-border-and-ripple-animations.  This is by design.

    If you need a border around the entire control you can subscribe to the GotFocus event and change the border color, width and box style: 
    public Form1()
    {
        InitializeComponent();
     
        this.radTextBoxControl1.GotFocus += radTextBoxControl1_GotFocus;
        this.radTextBoxControl1.LostFocus += radTextBoxControl1_LostFocus;
    }
     
    Color defaultBorderColor;
     
    private void radTextBoxControl1_LostFocus(object sender, EventArgs e)
    {
        this.radTextBoxControl1.TextBoxElement.BorderColor = defaultBorderColor ;
    }
     
    private void radTextBoxControl1_GotFocus(object sender, EventArgs e)
    {
        this.radTextBoxControl1.TextBoxElement.BorderBoxStyle = Telerik.WinControls.BorderBoxStyle.SingleBorder;
        defaultBorderColor = this.radTextBoxControl1.TextBoxElement.BorderColor;
        this.radTextBoxControl1.TextBoxElement.BorderColor = Color.Red ;
        this.radTextBoxControl1.TextBoxElement.BorderWidth = 1;
    }

    I hope this information helps. If you have any additional questions, please let me know. 

    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  22. Michael
    Michael avatar
    15 posts
    Member since:
    Nov 2014

    Posted 27 Jun in reply to Dess Link to this post

    Its sort of working but still doesn't look right.  You can see the orange of the typical color still and the bottom border is still thick (I tried setting textBox_Find.TextBoxElement.BorderWidth = 1;  but had no effect).  If Iturn off the EnableFocusBorder from the previous post then you see orange on the bottom that gradients to red at the top.  I don't understand why this isn't simpler.
  23. Dess
    Admin
    Dess avatar
    2164 posts

    Posted 29 Jun Link to this post

    Hello Michael, 

    Thank you for writing back. 

    Please refer to the attached sample project which result is illustrated in the attached gif file. If it is still not the desired look, it would be greatly appreciated if you can provide a screenshot of the exact goal that you are trying to achieve. Thus, we would be able to think about a suitable solution and assist you further. Thank you in advance.

    I hope this information helps. If you have any additional questions, please let me know. 

     Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  24. Michael
    Michael avatar
    15 posts
    Member since:
    Nov 2014

    Posted 29 Jun in reply to Dess Link to this post

    Thanks.  I got it now.  Part of the problem was that i was applying a theme to the entire form with ThemeResolutionService.ApplicationThemeName = "Office2010Silver";
  25. Dess
    Admin
    Dess avatar
    2164 posts

    Posted 03 Jul Link to this post

    Hello Michael, 

    Thank you for writing back. 

    If you apply the Office2010Silver theme to the entire application it is necessary to set the TextBoxElement.BorderGradientStyle property to Solid in addition to the previously provided code snippet:
    private void radTextBoxControl1_GotFocus(object sender, EventArgs e)
    {
        this.radTextBoxControl1.TextBoxElement.BorderBoxStyle = Telerik.WinControls.BorderBoxStyle.SingleBorder;
        defaultBorderColor = this.radTextBoxControl1.TextBoxElement.BorderColor;
        this.radTextBoxControl1.TextBoxElement.BorderColor = Color.Red ;
        this.radTextBoxControl1.TextBoxElement.BorderGradientStyle = GradientStyles.Solid;
        this.radTextBoxControl1.TextBoxElement.BorderWidth = 1;
    }

    I hope this information helps. If you have any additional questions, please let me know. 

    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top