Hi,
The idea is to change the "Text" value. Here's a start :
The idea is to change the "Text" value. Here's a start :
<local:MyDateTimePicker Format="ShortDate" />public class MyDateTimePicker : DateTimePicker
{
private bool _isChangingText = false;
protected override void OnTextChanged( string previousValue, string currentValue )
{
if( !_isChangingText && (currentValue.Count() == 8) )
{
var cultureInfo = Thread.CurrentThread.CurrentCulture;
var newValue = currentValue.Insert( 4, cultureInfo.DateTimeFormat.DateSeparator );
newValue = newValue.Insert( 7, cultureInfo.DateTimeFormat.DateSeparator );
_isChangingText = true;
this.Text = newValue;
_isChangingText = false;
return;
}
base.OnTextChanged( previousValue, currentValue );
}
}