GridSpinEditor allows Extra decimal places

3 posts, 0 answers
  1. SMCRadUser
    SMCRadUser avatar
    3 posts
    Member since:
    Sep 2009

    Posted 08 Jun 2012 Link to this post

    We have decided to go with an editable RadGridView for a particular project. We have run into some snags along the way which the forums have been very helpful. However, I have not noticed that anyone else has encountered this problem.

    I have a Decimal Column with the DecimalPlaces property set to 2. When there is already data in the column lets say "50.00" and you move over to that column, without entering edit mode, and just start typing a new value like "123.50", the GridSpinEditor allows the user to overwrite the first digits (as it should), but when you get to typing the decimal in 123.50 it stops the overwriting and starts inserting.

    This leaves a final text value of "123.50.00". When you hit enter the value magically changes to "1" in the grid.


    Can anyone explain this?

    I have a sample project. You can enter a value of 50 in column one. Then press enter to finalize it. Then, while the current cell is that same 50 cell, start typing 123.50. You will get 123.50.00 before the cell ends edit. And when it does end edit the final value will be 1.

    namespace RadControlsWinFormsApp2
    {
        partial class Form1
        {
            /// <summary>
            /// Required designer variable.
            /// </summary>
            private System.ComponentModel.IContainer components;
     
            /// <summary>
            /// Clean up any resources being used.
            /// </summary>
            /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
            protected override void Dispose(bool disposing)
            {
                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }
     
            #region Windows Form Designer generated code
     
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
                Telerik.WinControls.UI.GridViewDecimalColumn gridViewDecimalColumn2 = new Telerik.WinControls.UI.GridViewDecimalColumn();
                this.radGridView1 = new Telerik.WinControls.UI.RadGridView();
                this.radSpinEditor1 = new Telerik.WinControls.UI.RadSpinEditor();
                ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).BeginInit();
                ((System.ComponentModel.ISupportInitialize)(this.radSpinEditor1)).BeginInit();
                ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
                this.SuspendLayout();
                //
                // radGridView1
                //
                this.radGridView1.Location = new System.Drawing.Point(0, 0);
                //
                // radGridView1
                //
                gridViewDecimalColumn2.FieldName = "VALUE";
                gridViewDecimalColumn2.HeaderText = "column1";
                gridViewDecimalColumn2.Name = "column1";
                this.radGridView1.MasterTemplate.Columns.AddRange(new Telerik.WinControls.UI.GridViewDataColumn[] {
                gridViewDecimalColumn2});
                this.radGridView1.Name = "radGridView1";
                this.radGridView1.Size = new System.Drawing.Size(240, 150);
                this.radGridView1.TabIndex = 0;
                this.radGridView1.Text = "radGridView1";
                //
                // radSpinEditor1
                //
                this.radSpinEditor1.Location = new System.Drawing.Point(93, 180);
                this.radSpinEditor1.Name = "radSpinEditor1";
                //
                //
                //
                this.radSpinEditor1.RootElement.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.WrapAroundChildren;
                this.radSpinEditor1.ShowBorder = true;
                this.radSpinEditor1.Size = new System.Drawing.Size(100, 20);
                this.radSpinEditor1.TabIndex = 1;
                this.radSpinEditor1.TabStop = false;
                //
                // Form1
                //
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(292, 266);
                this.Controls.Add(this.radSpinEditor1);
                this.Controls.Add(this.radGridView1);
                this.Name = "Form1";
                //
                //
                //
                this.RootElement.ApplyShapeToControl = true;
                this.Text = "Form1";
                ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).EndInit();
                ((System.ComponentModel.ISupportInitialize)(this.radSpinEditor1)).EndInit();
                ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
                this.ResumeLayout(false);
                this.PerformLayout();
     
            }
     
            #endregion
     
            private Telerik.WinControls.UI.RadGridView radGridView1;
            private Telerik.WinControls.UI.RadSpinEditor radSpinEditor1;
        }
    }


    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Data;
     
    namespace RadControlsWinFormsApp2
    {
        public partial class Form1 : Telerik.WinControls.UI.RadForm
        {
            public Form1()
            {
                InitializeComponent();
     
                (radGridView1.Columns[0] as Telerik.WinControls.UI.GridViewDecimalColumn).DecimalPlaces = 2;
     
            }
        }
    }
  2. SMCRadUser
    SMCRadUser avatar
    3 posts
    Member since:
    Sep 2009

    Posted 11 Jun 2012 Link to this post

    /Bump ? 

    :-( 
  3. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 12 Jun 2012 Link to this post

    Hello Chris,

    Thank you for writing.

    There is no way to prevent the end-user from entering an invalid number (like 123.50.00) and a way to fall back the editor to default value (50.00)

    You can avoid this behavior only if you set the decimal place to 0. If this solution is not acceptable for you, you might want to change this column to GridViewMaskBoxColumn.

    Please refer to the sample project that demonstrates this approach.

    Greetings,
    Peter
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top