Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Editors (TextBox, MaskedEdit, SpinEditor, BrowseEditor, ColorBox) > RadTextBox BackColor not working?

Not answered RadTextBox BackColor not working?

Feed from this thread
  • Elizabeth avatar

    Posted on Apr 22, 2009 (permalink)

    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.

    Reply

  • David Mills avatar

    Posted on Apr 23, 2009 (permalink)

    I am having the same problem.

    Reply

  • Elizabeth avatar

    Posted on Apr 23, 2009 (permalink)

    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

    Reply

  • David Mills avatar

    Posted on Apr 23, 2009 (permalink)

    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

     

    Reply

  • Deyan Deyan admin's avatar

    Posted on Apr 24, 2009 (permalink)

    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.

    Reply

  • TwoLaJit avatar

    Posted on Jun 10, 2009 (permalink)

    This makes sense, I was wondering about this. This confirms it.

    Reply

  • Frank avatar

    Posted on Oct 14, 2011 (permalink)

    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

    Reply

  • Nikolay Nikolay admin's avatar

    Posted on Oct 17, 2011 (permalink)

    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.

    Reply

  • Frank avatar

    Posted on Oct 17, 2011 (permalink)

    Thanks - and I'll try out radcontrolspy.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Editors (TextBox, MaskedEdit, SpinEditor, BrowseEditor, ColorBox) > RadTextBox BackColor not working?
Related resources for "RadTextBox BackColor not working?"

[ Features | Demos | Documentation | Knowledge Base | Telerik TV | Code Library | Step-by-step Tutorial | Blogs | Self-Paced Trainer ]