This is a migrated thread and some comments may be shown as answers.

How to change the border color using reference to a control

1 Answer 325 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
Filleau
Top achievements
Rank 1
Filleau asked on 11 Apr 2012, 08:08 AM
Hi,

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 :

DirectCast

 

 

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

Thanks for your help

1 Answer, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 13 Apr 2012, 03:01 PM
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.
 
Regards,
Stefan
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
TextBox
Asked by
Filleau
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or