Text Formatting

11 posts, 0 answers
  1. Blair
    Blair avatar
    3 posts
    Member since:
    Aug 2008

    Posted 21 Aug 2008 Link to this post

    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
  2. Hristo Borisov
    Admin
    Hristo Borisov avatar
    298 posts

    Posted 22 Aug 2008 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. JTango
    JTango avatar
    24 posts
    Member since:
    Jan 2007

    Posted 02 Sep 2008 Link to this post

    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

  5. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 02 Sep 2008 Link to this post

    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.
  6. JTango
    JTango avatar
    24 posts
    Member since:
    Jan 2007

    Posted 02 Sep 2008 Link to this post

    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
  7. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 03 Sep 2008 Link to this post

    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.
  8. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 04 Sep 2008 Link to this post

    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.
  9. JTango
    JTango avatar
    24 posts
    Member since:
    Jan 2007

    Posted 08 Sep 2008 Link to this post

    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
  10. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 09 Sep 2008 Link to this post

    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.
  11. Jacquest Croussette
    Jacquest Croussette avatar
    1 posts
    Member since:
    Jan 2009

    Posted 20 Jul 2010 Link to this post

    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

     

  12. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 22 Jul 2010 Link to this post

    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
Back to Top
UI for WPF is Visual Studio 2017 Ready