Formatting TextBoxes

2 posts, 0 answers
  1. Scott
    Scott avatar
    36 posts
    Member since:
    Dec 2015

    Posted 14 Jul 2016 Link to this post

    I have been trying to find a way to format textboxes to currency.  This is the only thing I have found that works:


    this.feeTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.BindingSource, "DataColumnName", true, System.Windows.Forms.DataSourceUpdateMode.OnValidation, null, "C0"));


    Basically, this [ System.Windows.Forms.DataSourceUpdateMode.OnValidation, null, "C0" ] gets added as parameters in the Binding() function.

    Has anyone run into problems using this method?  Does anyone have additional information on the formatting options available?



  2. Hristo
    Hristo avatar
    1520 posts

    Posted 15 Jul 2016 Link to this post

    Hi Scott,

    Thank you for writing.

    I think that you could also achieve your task with a RadMaskedEditBox control having a numeric mask set to currency:

    I also tested the described scenario. On my end, the text box successfully binds to the specified field: 
    public partial class Form1 : Form
        BindingSource source;
        public Form1()
            Model m = new Model() { DataColumnName = 5 };
            this.source = new BindingSource();
            this.source.DataSource = m;
            this.radTextBox1.DataBindings.Add(new Binding("Text", this.source, "DataColumnName", true, System.Windows.Forms.DataSourceUpdateMode.OnValidation, null, "C0"));
    public class Model
        public int DataColumnName { get; set; }

    Could you please check how the solution runs on your end? In case you keep experiencing the issue, please share some more details about your scenario and a code snippet if possible.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Hristo Merdjanov
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Back to Top