As I understand it, percentage handling in the NumericUpDown control is supposed to behave like Excel. Here is the behavior of a cell formatted as a percentage in Excel 2007 SP2:
Enter in 1 - Excel displays 1.00%
Enter in .01 - Excel displays 1.00%
Enter in 500 - Excel displays 500.00%
Enter in .5 - Excel displays 50.00%
I'm using this XAML:
<Grid x:Name="LayoutRoot" >
<telerik:RadNumericUpDown x:Name="numericUpDown" />
</Grid>
With this C# code-behind:
public CEBOSNumericUpDown()
{
InitializeComponent();
}
public ValueFormat NumericValueFormat
{
get
{
return this.numericUpDown.ValueFormat;
}
set
{
this.numericUpDown.ValueFormat = value;
if (value == ValueFormat.Percentage)
{
this.numericUpDown.SmallChange = .005;
}
}
}
Being called with ValueFormat=ValueFormat.Percentage and bound to a class property that is defined as a double.
I get the following behavior:
Enter in 1 - Get 100%
Enter in 1.0 - Get 1000%
Enter in 0.01 - Get 100%
Enter in 500 - Get 50,000%
Enter in .5 - Get 500%
Note that, in order to clear the previous value, have to hit backspace to clear the control - typing while the control's contents are highlighted does not overwrite the contents as is standard on pretty much every other control. The control also does not display decimals at all, which is the behavior in Excel.
How can I duplicate Excel's handling of percentages in this control, or is it possible at all?
Enter in 1 - Excel displays 1.00%
Enter in .01 - Excel displays 1.00%
Enter in 500 - Excel displays 500.00%
Enter in .5 - Excel displays 50.00%
I'm using this XAML:
<Grid x:Name="LayoutRoot" >
<telerik:RadNumericUpDown x:Name="numericUpDown" />
</Grid>
With this C# code-behind:
public CEBOSNumericUpDown()
{
InitializeComponent();
}
public ValueFormat NumericValueFormat
{
get
{
return this.numericUpDown.ValueFormat;
}
set
{
this.numericUpDown.ValueFormat = value;
if (value == ValueFormat.Percentage)
{
this.numericUpDown.SmallChange = .005;
}
}
}
Being called with ValueFormat=ValueFormat.Percentage and bound to a class property that is defined as a double.
I get the following behavior:
Enter in 1 - Get 100%
Enter in 1.0 - Get 1000%
Enter in 0.01 - Get 100%
Enter in 500 - Get 50,000%
Enter in .5 - Get 500%
Note that, in order to clear the previous value, have to hit backspace to clear the control - typing while the control's contents are highlighted does not overwrite the contents as is standard on pretty much every other control. The control also does not display decimals at all, which is the behavior in Excel.
How can I duplicate Excel's handling of percentages in this control, or is it possible at all?