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

Binding the textBox border color.

2 Answers 240 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
Igor
Top achievements
Rank 1
Igor asked on 06 Feb 2012, 02:28 PM
Hello,

In order to change the border color of the TextBox i use:
textBox1.TextBoxElement.Border.ForeColor = Color.Red;
How can i achieve this using data binding?

Looking forward to your reply.      

2 Answers, 1 is accepted

Sort by
0
Boryana
Telerik team
answered on 07 Feb 2012, 01:14 PM
Hi Igor,

Thank you for writing.

You can use the simple binding mechanism to bind the ForeColor property to the Text property of another control, for example:
RadTextBox textBox1 = new RadTextBox();
RadTextBox textBox2 = new RadTextBox();
textBox1.DataBindings.Add("Text", textBox2.TextBoxElement.Border, "ForeColor", true, DataSourceUpdateMode.OnPropertyChanged);

I hope this helps. Feel free to ask if you have any additional questions.  

Kind regards,
Juliana
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Boryana
Telerik team
answered on 08 Feb 2012, 12:23 PM
Hi Igor,

Please consider the following approach:
public partial class Form1 : Form
{
    private void Form1_Load(object sender, EventArgs e)
    {
        this.myTextBox1.DataBindings.Add("BorderColor", MyObj, "Color");
    }
}
 
public class MyTextBox : RadTextBox
{
    public Color BorderColor
    {
        get
        {
            return this.TextBoxElement.Border.ForeColor;
        }
        set
        {
            this.TextBoxElement.Border.ForeColor = value;
            OnNotifyPropertyChanged("BorderColor");
        }
    }
 
    public override string ThemeClassName
    {
        get
        {
            return typeof(RadTextBox).FullName;
        }
    }
}

I hope this is the solution you are looking for. Let me know if you have further questions.

Kind regards,
Boryana
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
TextBox
Asked by
Igor
Top achievements
Rank 1
Answers by
Boryana
Telerik team
Share this question
or