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

Formatting TextBoxes

1 Answer 233 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 14 Jul 2016, 12:05 PM

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?

 

Thanks!

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 15 Jul 2016, 07:53 AM
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: http://docs.telerik.com/devtools/winforms/editors/maskededitbox/numeric-masks.

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()
    {
        InitializeComponent();
         
        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.

Regards,
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.
Tags
TextBox
Asked by
Scott
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or