We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How can I hide the Zeros displayed when I set the property "CurrencyDecimalDigits" ?


We can workaround the behaviour for now by handling the GotFocus and LostFocus events of CurrencyTextBox.Though we cannot hide the zeros ,you can set it in such a way that whenever the control does not have focus,it hides zeros.However, when it gets focus it shows the zeros according to the decimal digits.


private void currencyTextBox1_GotFocus(object sender, System.EventArgs e)


this.currencyTextBox1.CurrencyDecimalDigits = 6;



private void currencyTextBox1_LostFocus(object sender, System.EventArgs e)


string dblval = this.currencyTextBox1.DecimalValue.ToString();

int decimalpos = this.currencyTextBox1.Text.IndexOf(".");

int len = dblval.TrimEnd(''0'').Substring(decimalpos).Length;

this.currencyTextBox1.CurrencyDecimalDigits = len;



Private Sub currencyTextBox1_GotFocus(ByVal sender As Object, ByVal e As EventArgs) Handles currencyTextBox1.GotFocus

Me.currencyTextBox1.CurrencyDecimalDigits = 6

End Sub


Private Sub currencyTextBox1_LostFocus(ByVal sender As Object, ByVal e As EventArgs) Handles currencyTextBox1.LostFocus

Dim dblval As String = Me.currencyTextBox1.DecimalValue.ToString()

Dim decimalpos As Integer = Me.currencyTextBox1.Text.IndexOf(".")

Dim len As Integer = dblval.TrimEnd("0"c).Substring(decimalpos).Length

Me.currencyTextBox1.CurrencyDecimalDigits = len

End Sub

Article ID: Published Date: Last Revised Date: Platform: Control:
1394 04/30/2011 07/10/2014 WinForms CurrencyTextBox
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Please sign in to access our KB

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon