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

Text Formatting

10 Answers 355 Views
NumericUpDown
This is a migrated thread and some comments may be shown as answers.
Blair
Top achievements
Rank 1
Blair asked on 21 Aug 2008, 05:09 PM
I am trying to use the NumericUpDown but I need to format the displayed value so as to not show anything after the decimal, i.e. I want whole numbers only. I cannot seem to find a text format property, so how can I achieve this?

Thanks,

blair

10 Answers, 1 is accepted

Sort by
0
Hristo Borisov
Telerik team
answered on 22 Aug 2008, 11:24 AM
Hi Blair,

To have integers you should set NumberFormatInfo.NumberDecimalDigits = 0 in case the ValueFormat property is set to Numeric. If you want to use integers for Percentage or Currency, you should change the ValueFormat property to the appropriate one, and then set the corresponding DecimalDigits property of NumberFormatInfo to 0.

Please have a look at http://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo_properties.aspx where all format options are available.

All the best,
Hristo Borisov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
JTango
Top achievements
Rank 1
answered on 02 Sep 2008, 09:03 AM
This seems a little convuluted to me.

1. Because I can't just set a format in XAML using a string
and
2.
                   <telerik:RadNumericUpDown.NumberFormatInfo>
                        <globalization:NumberFormatInfo NumberDecimalDigits="0"/>
                    </telerik:RadNumericUpDown.NumberFormatInfo>
doesn't seem to have any affect.

While it may all well and good to set the value in C# code behind, this severely limits the usefulness of the control in DataTemplate situations.

The documentation also mentions setting ValueFormat to custom, which doesn't appear to be an option in Q2 release of the controls.

Justin Taylor

0
Valeri Hristov
Telerik team
answered on 02 Sep 2008, 02:58 PM
Hello Justin,

I used the following XAML successfuly:

<

Window x:Class="RadComboBoxTestWpf.Window1"
    xmlns:n
="clr-namespace:System.Globalization;assembly=mscorlib"
    xmlns:t
="http://schemas.telerik.com/2008/xaml/presentation"
    xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    
Title="Window1" Height
="300" Width="300">
    <Grid
>
        <t:RadNumericUpDown SmallChange="1" Minimum="0" Maximum
="100">
            <t:RadNumericUpDown.NumberFormatInfo
>
                <n:NumberFormatInfo NumberDecimalDigits
="0" />
            </t:RadNumericUpDown.NumberFormatInfo
>
        </t:RadNumericUpDown
>
    </Grid
>
</
Window>

Am I missing something?

Regarding the text for setting ValueFormat=Custom - this is a mistake, that will be fixed as soon as possible.

All the best,
Valeri Hristov (Silverlight Team)
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
JTango
Top achievements
Rank 1
answered on 03 Sep 2008, 12:55 AM
Nope, you didn't miss anything. My code was identical to that except my namespaces were not n and t, they were globalization and telerik respectively, but that shouldn't make any difference.

Mine was inside a DataTemplate which seems to make the difference.

I have a sample project ready to go if you'd like me to email it to you.

Regards

Justin
0
Valeri Hristov
Telerik team
answered on 03 Sep 2008, 02:50 PM
Hello Innocence18,

Yes, please, email it to valeri at telerik dot com. I will try to respond with a solution as soon as possible.

All the best,
Valeri Hristov (Silverlight Team)
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Valeri Hristov
Telerik team
answered on 04 Sep 2008, 04:39 PM
Hello Justin,

I managed to reproduce and fix the problem. The upcoming service pack of RadControls for WPF will contain the fix. Thank you for your feedback, your points have been updated!

Sincerely yours,
Valeri Hristov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
JTango
Top achievements
Rank 1
answered on 09 Sep 2008, 01:47 AM
Any chances of getting a timeframe for delivery of the service pack. This is something we'd like to use as soon as possible.

Regards

Justin
0
Valeri Hristov
Telerik team
answered on 09 Sep 2008, 10:16 AM
Hello Justin,

We are going to update the controls later today.

Kind regards,
Valeri Hristov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jacquest Croussette
Top achievements
Rank 1
answered on 20 Jul 2010, 08:38 PM
I've recently upgraded to version RadControls_for_WPF_2010_1_0603_DEV.msi

I have a RadNumericUpDown control inside a DataTemplate, that gets selected via a TemplateSelector, and the NumberFormatInfo seems to have no effect.  Is this problem back, or was it ever fixed in a non-service pack release?

Following is my XAML code block that defines the RadNumericUpDown:

 

 

<telerik:RadNumericUpDown Grid.Row="3" Grid.Column="1"

 

 

VerticalAlignment="Center"

 

 

HorizontalAlignment="Stretch"

 

 

Foreground="Black"

 

 

IsEnabled="{Binding ElementName=IsAssignedInspectorCheckBox, Path=IsChecked}"

 

 

Value="{Binding Path=Response.ResponseNumeric, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"

 

 

CustomUnit="{Binding ElementName=UnitLabel, Path=Content}"

 

 

ValueChanged="NumericValue_Changed"

 

 

ValueFormat="Numeric" SmallChange="1" LargeChange="50" Minimum="0" Maximum="2000000" >

 

 

 

<telerik:RadNumericUpDown.NumberFormatInfo>

 

 

 

<globalization:NumberFormatInfo NumberDecimalDigits="0" />

 

 

 

</telerik:RadNumericUpDown.NumberFormatInfo>

 

 

 

</telerik:RadNumericUpDown>

Thanks

 

0
Valeri Hristov
Telerik team
answered on 22 Jul 2010, 09:09 AM
Hi Jacquest,

I had to remove some of your code in order to test the sample (the bindings to IsEnabled, Value and CustomUnit), but everything seems to work as expected. Could you please send me a simple application that can be used to observe the problem?

By the way, you could set IsInteger=true on RadNumericUpDown to achieve the same effect, without declaring NumberFormatInfo.

Regards,
Valeri Hristov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
NumericUpDown
Asked by
Blair
Top achievements
Rank 1
Answers by
Hristo Borisov
Telerik team
JTango
Top achievements
Rank 1
Valeri Hristov
Telerik team
Jacquest Croussette
Top achievements
Rank 1
Share this question
or