Completed
Last Updated: 01 Feb 2021 07:41 by ADMIN
Release LIB 2021.1.201 (2/1/2021)
Martin Ivanov
Created on: 20 Jan 2021 08:11
Category: NumericUpDown
Type: Bug Report
0
NumericUpDown: Allow pasting numeric strings with leading and trailing white space characters

Currently, the control doesn't allow to paste numeric strings with leading and trailing white spaces. For example " 35 ".

To achieve this, you can subscribe the RadNumericUpDown control to the Pasting event and implement the pasting manually. 

DataObject.AddPastingHandler(this.numericUpDown, OnNumericUpDownPaste);


private void OnNumericUpDownPaste(object sender, DataObjectPastingEventArgs e)
{
	var copiedString = e.DataObject.GetData(typeof(string)) as string;
	if (copiedString != null)
	{
		copiedString = copiedString.Trim();
		double number = 0;
		var success = double.TryParse(copiedString, out number);
		if (success)
		{
			this.numericUpDown.SetCurrentValue(RadNumericUpDown.ValueProperty, number);
			e.CancelCommand();
		}
	}
}

0 comments