RadTextBox BackColor not working?

15 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. UI for WinForms is Visual Studio 2017 Ready
  4. 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
  5. 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

     

  6. Deyan
    Admin
    Deyan avatar
    2041 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.
  7. 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.
  8. 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
  9. Nikolay
    Admin
    Nikolay avatar
    1804 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.

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

    Posted 17 Oct 2011 Link to this post

    Thanks - and I'll try out radcontrolspy.
  11. 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!
  12. Stefan
    Admin
    Stefan avatar
    2890 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.
  13. 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)?
  14. Stefan
    Admin
    Stefan avatar
    2890 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 >>
  15. Ke
    Ke avatar
    18 posts
    Member since:
    Feb 2016

    Posted 09 Mar 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? 

  16. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 10 Mar 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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready