Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Editors (TextBox, MaskedEdit, SpinEditor, BrowseEditor, ColorBox) > Binding the textBox border color.

Not answered Binding the textBox border color.

Feed from this thread
  • Igor avatar

    Posted on Feb 6, 2012 (permalink)

    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.      

    Reply

  • Boryana Boryana admin's avatar

    Posted on Feb 7, 2012 (permalink)

    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 >>

    Reply

  • Boryana Boryana admin's avatar

    Posted on Feb 8, 2012 (permalink)

    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 >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Editors (TextBox, MaskedEdit, SpinEditor, BrowseEditor, ColorBox) > Binding the textBox border color.
Related resources for "Binding the textBox border color."

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