GrapeCity MultiRow Windows Forms Documentation
DecimalPlaces Property
Example 


Gets or sets the number of decimal places to display in the NumericUpDownCell object.
Syntax
<DefaultValueAttribute()>
<SRDescriptionAttribute("Indicates the number of decimal places to display.")>
<SRCategoryAttribute("Data")>
Public Property DecimalPlaces As Integer
Dim instance As NumericUpDownCell
Dim value As Integer
 
instance.DecimalPlaces = value
 
value = instance.DecimalPlaces
[DefaultValue()]
[SRDescription("Indicates the number of decimal places to display.")]
[SRCategory("Data")]
public int DecimalPlaces {get; set;}

Property Value

A System.Int32 value that represents the number of decimal places to display in the NumericUpDownCell. The default is 0.
Exceptions
ExceptionDescription
System.ArgumentOutOfRangeException

The assigned value is less than 0.

-or-

The assigned value is greater than 99.

Remarks

The appropriate decimal symbol is determined by the regional settings of the user's operating system.

Refer to the System.Windows.Forms.NumericUpDown control for details in MSDN.

Example
The following code example shows some important properties of NumericUpDownCell. In the first column, the Minimum is 0 and the Maximum is 10. Enter edit mode and the text is selected. You can use the arrow keys (left, right, up, or down key) to increase or decrease the value. Press the key once, and the value increases or decreases by 0.01. When you select a cell, the UpDown button displays. In the second column, the value displays as hexadecimal. The initial value, 15, displays as "F", and the UpDown button is aligned to the left. If the text cannot display completely, an ellipsis string is shown in the middle. This example is part of a larger example available for the NumericUpDownCell class.
private void Form1_Load(object sender, EventArgs e)
        {
            NumericUpDownCell numericUpDownCell1 = new NumericUpDownCell();

            //The minimum value is 0, maximum value is 10, initial value is 0;
            numericUpDownCell1.Minimum = 0;
            numericUpDownCell1.Maximum = 10;
            numericUpDownCell1.Value = 0;
            //Use the Left, Right, Up, and Down keys.
            numericUpDownCell1.InterceptArrowKeys = true;
            //Select a cell, the SpinButton displays.
            numericUpDownCell1.ShowSpinButton = CellButtonVisibility.ShowForCurrentCell;
            numericUpDownCell1.DecimalPlaces = 2;
            //Press the arrow key, the value increases by 0.01
            numericUpDownCell1.Increment = 0.01m;
            //Enter edit mode, the text is selected.
            numericUpDownCell1.HighlightText = true;

            NumericUpDownCell numericUpDownCell2 = new NumericUpDownCell();
            numericUpDownCell2.Value = 16m;
            //The value displays as hexadecimal.
            numericUpDownCell2.Hexadecimal = true;
            //The initial value is 15, it displays 'F'
            numericUpDownCell2.Value = 15;
            //The UpDown button aligns to left.
            numericUpDownCell2.UpDownAlign = LeftRightAlignment.Left;
            //The thousand separator ',' is inserted.
            numericUpDownCell2.ThousandsSeparator = true;
            //Press the Up or Down key, after 2 seconds, the value increases by 50, after 6 seconds, by 300.
            numericUpDownCell2.Accelerations.AddRange(new NumericUpDownAcceleration[] { new 
NumericUpDownAcceleration(2, 50), new NumericUpDownAcceleration(6, 300) });
            //If the value cannot be displayed completely, an ellipsis string is shown in the middle.
            numericUpDownCell2.Ellipsis = MultiRowEllipsisMode.EllipsisPath;
            numericUpDownCell2.EllipsisString = "...";

            Template template1 = Template.CreateGridTemplate(new Cell[] { numericUpDownCell1, 
numericUpDownCell2 }, Int32.MaxValue,
                AutoGenerateGridTemplateStyles.ColumnHeader | 
AutoGenerateGridTemplateStyles.RowHeaderAutoNumber);
            template1.ColumnHeaders[0].Cells[0].Value = "Column1";
            template1.ColumnHeaders[0].Cells[1].Value = "Column2";

            gcMultiRow1.Template = template1;
            gcMultiRow1.RowCount = 10;
        }
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        Dim numericUpDownCell1 As New NumericUpDownCell()

        'The minimum value is 0, maximum value is 10, initial value is 0;
        numericUpDownCell1.Minimum = 0
        numericUpDownCell1.Maximum = 10
        numericUpDownCell1.Value = 0
        'Use the Left, Right, Up, and Down keys.
        numericUpDownCell1.InterceptArrowKeys = True
        'Select a cell, the SpinButton displays.
        numericUpDownCell1.ShowSpinButton = CellButtonVisibility.ShowForCurrentCell
        numericUpDownCell1.DecimalPlaces = 2
        'Press the arrow key, the value increases by 0.01
        numericUpDownCell1.Increment = 0.01D
        'Enter edit mode, the text is selected.
        numericUpDownCell1.HighlightText = True

        Dim numericUpDownCell2 As New NumericUpDownCell()
        numericUpDownCell2.Value = 16D
        'The value displays as hexadecimal.
        numericUpDownCell2.Hexadecimal = True
        'The initial value is 15, it displays 'F'
        numericUpDownCell2.Value = 15
        'The UpDown button aligns to left.
        numericUpDownCell2.UpDownAlign = LeftRightAlignment.Left
        'The thousand separator ',' is inserted.
        numericUpDownCell2.ThousandsSeparator = True
        'Press the Up or Down key, after 2 seconds, the value increases by 50, after 6 seconds, by 300.
        numericUpDownCell2.Accelerations.AddRange(New NumericUpDownAcceleration() {New 
NumericUpDownAcceleration(2, 50), New NumericUpDownAcceleration(6, 300)})
        'If the value cannot be displayed completely, an ellipsis string is shown in the middle.
        numericUpDownCell2.Ellipsis = MultiRowEllipsisMode.EllipsisPath
        numericUpDownCell2.EllipsisString = "..."

        Dim template1 As Template = Template.CreateGridTemplate(New Cell() {numericUpDownCell1, 
numericUpDownCell2})
        template1.ColumnHeaders(0).Cells(0).Value = "Column1"
        template1.ColumnHeaders(0).Cells(1).Value = "Column2"

        gcMultiRow1.Template = template1
        gcMultiRow1.RowCount = 10
    End Sub
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

NumericUpDownCell Class
NumericUpDownCell Members

 

 


Copyright © GrapeCity, inc. All rights reserved.