Completed
Last Updated: 14 Jun 2016 07:37 by Mieke
ADMIN
Dess | Tech Support Engineer, Sr.
Created on: 12 May 2016 12:18
Category: Editors
Type: Bug Report
1
FIX. RadDateTimePicker- pasted date value is replaced with a new one
To reproduce:

this.radDateTimePicker1.Format = DateTimePickerFormat.Short;
this.radDateTimePicker1.Value = new DateTime(2016, 5, 12);
this.radTextBox1.Text = "9/5/2016";

Second scenario:

this.radDateTimePicker1.Format = DateTimePickerFormat.Short;

If you copy "1/7/16" and paste it into RadDateTimeicker, the result date will be "1/7/1616". In the previous version, the result was correct 1/7/2016.

Copy the value in the text box and paste it in RadDateTimePicker.

Workaround: 

public Form1()
{
    InitializeComponent();
    this.radDateTimePicker1.Format = DateTimePickerFormat.Short;
    this.radDateTimePicker1.Value = new DateTime(2016, 5, 12);
    this.radTextBox1.Text = "9/5/2016";
    this.radDateTimePicker1.ValueChanging += radDateTimePicker1_ValueChanging;

    this.radDateTimePicker1.DateTimePickerElement.TextBoxElement.TextBoxItem.TextBoxControl.KeyPress += TextBoxControl_KeyPress; 
}

string clipboardData;

private void TextBoxControl_KeyPress(object sender, KeyPressEventArgs e)
{
    if (e.KeyChar == '\x16')
    {
        if (clipboardData != null)
        {
            this.radDateTimePicker1.Text = clipboardData;
            clipboardData = null;
        }
    }
}

private void radDateTimePicker1_ValueChanging(object sender, Telerik.WinControls.UI.ValueChangingEventArgs e)
{
    if (clipboardData == null)
    {
        clipboardData = RadMaskedEditBoxElement.GetClipboardText();
    }
}
Attached Files:
1 comment
Mieke
Posted on: 19 May 2016 07:54
For a global solution a created a class that can be used :

    DatePickerClipboardManager MyDatePickerSystem = 
        newDatePickerClipboardManager(
            newList<Telerik.WinControls.UI.RadDateTimePicker>(
                newTelerik.WinControls.UI.RadDateTimePicker[] {
                         datePickker1,
                         datePickker2,
                         datePickker3,
                         datePickker4}));
         }



        public class DatePickerClipboardManager
        {

            List<ClipboardHolder> MyDatePickersClipboard = new List<ClipboardHolder>();

            public DatePickerClipboardManager(List<Telerik.WinControls.UI.RadDateTimePicker> MyDatePickerList)
            {
                MyDatePickersClipboard.Clear();
                foreach (Telerik.WinControls.UI.RadDateTimePicker obj in MyDatePickerList)
                {
                    if (obj != null)
                    {
                        obj.ValueChanging += radDateTimePicker1_ValueChanging;
                        obj.DateTimePickerElement.TextBoxElement.TextBoxItem.TextBoxControl.KeyPress += TextBoxControl_KeyPress;
                        MyDatePickersClipboard.Add(new ClipboardHolder(obj, null));
                    }
                }
            }

            private void TextBoxControl_KeyPress(object sender, KeyPressEventArgs e)
            {
                
                if (e.KeyChar == '\x16')
                {
                    foreach (ClipboardHolder MyObj in MyDatePickersClipboard)
                    {
                        if (object.ReferenceEquals(MyObj.MyDatePicker, ((System.Windows.Forms.TextBox)(sender)).Parent)) 
                        {
                            if (MyObj.MyDataClipboard != null)
                            {
                                System.Diagnostics.Debug.WriteLine("Keypress in : " + MyObj.MyDatePicker.Name.ToString());
                                MyObj.MyDatePicker.Text = MyObj.MyDataClipboard;
                                MyObj.MyDataClipboard = null;
                            }
                        }
                    }
                }
            }

            private void radDateTimePicker1_ValueChanging(object sender, Telerik.WinControls.UI.ValueChangingEventArgs e)
            {
               foreach (ClipboardHolder MyObj in MyDatePickersClipboard)
                {
                    if (object.ReferenceEquals(MyObj.MyDatePicker, sender))
                    {
                        if (MyObj.MyDataClipboard == null)
                        {
                            System.Diagnostics.Debug.WriteLine("Value Changed in : " + MyObj.MyDatePicker.Name.ToString());
                            MyObj.MyDataClipboard = Telerik.WinControls.UI.RadMaskedEditBoxElement.GetClipboardText();
                        }
                    }
                }
            }


        }




        public class ClipboardHolder
        {

            Telerik.WinControls.UI.RadDateTimePicker _MyDatePicker = null;
            string _MyDataClipboard = null;

            public Telerik.WinControls.UI.RadDateTimePicker MyDatePicker
            {
                get
                {
                    return _MyDatePicker;
                }
                set
                {
                    _MyDatePicker = value;
                }

            }

            public string MyDataClipboard
            {
                get
                {
                    return _MyDataClipboard;
                }
                set
                {
                    _MyDataClipboard = value;
                }
            }

            public ClipboardHolder(Telerik.WinControls.UI.RadDateTimePicker MyDatePickerObject, string MyDatePikerClipboard)
            {
                _MyDataClipboard = MyDatePikerClipboard;
                _MyDatePicker = MyDatePickerObject;

            }

        }