From 7b66fb35fb457e1f51d6b1ec1e60a7eb7ca01da7 Mon Sep 17 00:00:00 2001 From: KB Bot Date: Mon, 30 Sep 2024 11:34:46 +0000 Subject: [PATCH 1/2] Added new kb article numeric-textbox-kb-zero-decimals --- .../numeric-textbox-kb-zero-decimals.md | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 knowledge-base/numeric-textbox-kb-zero-decimals.md diff --git a/knowledge-base/numeric-textbox-kb-zero-decimals.md b/knowledge-base/numeric-textbox-kb-zero-decimals.md new file mode 100644 index 0000000000..00e0f5c2d6 --- /dev/null +++ b/knowledge-base/numeric-textbox-kb-zero-decimals.md @@ -0,0 +1,51 @@ +--- +title: How to Display Currency Format Without Decimals +description: Learn how to display a currency value without decimal places in a Blazor NumericTextBox by adjusting the Format and Decimals parameters. +type: how-to +page_title: How to Display Currency Format Without Decimals +slug: numeric-textbox-kb-zero-decimals +tags: numeric-textbox, blazor, format, decimals, currency +res_type: kb +ticketid: 1661907 +--- + +## Environment + + + + + + + +
ProductNumericTextBox for Blazor
+ +## Description + +When using the [NumericTextBox](https://docs.telerik.com/blazor-ui/components/numerictextbox/overview) with a currency format, setting the `Decimals` parameter to 0 does not prevent decimal places from being displayed. This occurs because the `Format="C"` parameter, which specifies currency formatting, overrides the `Decimals` parameter by adding two decimal places by default, according to the local currency settings (e.g., £). + +This KB article also answers the following questions: +- How to display currency values without decimals in a NumericTextBox? +- How to use the Format parameter to control decimal places in NumericTextBox? +- What is the effect of the Decimals parameter in NumericTextBox when using currency format? + +## Solution + +To display a currency value without decimal places in the NumericTextBox while using the currency format (`C`), set the `Format` parameter to `"C0"`. This explicitly sets the number of decimal places to zero in the formatted currency value. + +````CSHTML + + + +@code { + private decimal BoundAmountTo { get; set; } = 20.00m; +} + +```` + +It is crucial to understand that the `Decimals` parameter only affects the allowed decimal places during typing (when the input is focused). Conversely, the `Format` parameter determines how the value is displayed when the input is not focused, including the number of decimal places shown in the formatted output. + +## See Also + +- [NumericTextBox Overview](https://docs.telerik.com/blazor-ui/components/numerictextbox/overview) +- [NumericTextBox Parameters](https://docs.telerik.com/blazor-ui/components/numerictextbox/overview#numeric-textbox-parameters) +- [Standard Numeric Format Strings - Currency Format Specifier (C)](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings#currency-format-specifier-c) From c2f5803f366107c6241a71911483631076150cfb Mon Sep 17 00:00:00 2001 From: Tsvetomir Hristov <106250052+Tsvetomir-Hr@users.noreply.github.com> Date: Mon, 30 Sep 2024 15:25:04 +0300 Subject: [PATCH 2/2] docs(NumericTextBox): kb polish --- knowledge-base/numeric-textbox-kb-zero-decimals.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/knowledge-base/numeric-textbox-kb-zero-decimals.md b/knowledge-base/numeric-textbox-kb-zero-decimals.md index 00e0f5c2d6..2830b61d22 100644 --- a/knowledge-base/numeric-textbox-kb-zero-decimals.md +++ b/knowledge-base/numeric-textbox-kb-zero-decimals.md @@ -21,7 +21,7 @@ ticketid: 1661907 ## Description -When using the [NumericTextBox](https://docs.telerik.com/blazor-ui/components/numerictextbox/overview) with a currency format, setting the `Decimals` parameter to 0 does not prevent decimal places from being displayed. This occurs because the `Format="C"` parameter, which specifies currency formatting, overrides the `Decimals` parameter by adding two decimal places by default, according to the local currency settings (e.g., £). +When using the [NumericTextBox]({%slug components/numerictextbox/overview%}) with a currency format, setting the `Decimals` parameter to 0 does not prevent decimal places from being displayed. This occurs because the `Format="C"` parameter, which specifies currency formatting, overrides the `Decimals` parameter by adding two decimal places by default, according to the local currency settings (e.g., £). This KB article also answers the following questions: - How to display currency values without decimals in a NumericTextBox? @@ -46,6 +46,5 @@ It is crucial to understand that the `Decimals` parameter only affects the allow ## See Also -- [NumericTextBox Overview](https://docs.telerik.com/blazor-ui/components/numerictextbox/overview) -- [NumericTextBox Parameters](https://docs.telerik.com/blazor-ui/components/numerictextbox/overview#numeric-textbox-parameters) +- [NumericTextBox Parameters]({%slug components/numerictextbox/overview%}#numeric-textbox-parameters) - [Standard Numeric Format Strings - Currency Format Specifier (C)](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings#currency-format-specifier-c)