How to change the border color using reference to a control

2 posts, 1 answers
  1. Filleau
    Filleau avatar
    114 posts
    Member since:
    Jun 2006

    Posted 11 Apr 2012 Link to this post


    I'm trying to change the border color on a RadTextBox.
    It should be easy using the control, but in my case the radtextbox is stored in a var.
    Here a sample


    Dim controle As String = CType(sender, RadTextBox).Name
     ' Change the text : It works !
    Controls(controle).Text = "Hello, World"
     ' Change the border = DON'T WORK
    DirectCast(Me.Controls(controle).TextBoxElement.Children(2), Telerik.WinControls.Primitives.BorderPrimitive).ForeColor = Color.Red


    So I can change the text, but I have a problem with this line (.textBoxElement) not present :




    Me.controls(controle).TextBoxElement.Children(2), Telerik.WinControls.Primitives.BorderPrimitive).ForeColor = Color.Red

    Thanks for your help

  2. Answer
    Stefan avatar
    2908 posts

    Posted 13 Apr 2012 Link to this post

    Hi Mr Filleau,

    Thank you for writing.

    I assume that you want to change the text box border color in some event handler, where the sender is RadTextBox control. If so, please consider the following code snippet:
    DirectCast(sender, RadTextBox).TextBoxElement.Border.ForeColor = Color.Red

    I hope this helps. 

    Let us know if you have any other questions.
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top