Hello John,
I would suggest creating a custom RadDateTimePicker and create an an FormatProvider event, that would handle the value changed event of the control, in order to change the display text based on one of your methods of date conversion.
using
System.Windows.Forms;
using
Telerik.WinControls.UI;
namespace
TestDateTimePickerCustomFormat
{
using
System;
using
System.Drawing;
public
partial
class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
this
.Load +=
new
EventHandler(Form1_Load);
this
.Size =
new
Size(200, 60);
}
void
Form1_Load(
object
sender, EventArgs e)
{
var customDateTimePicker1 =
new
CustomDateTimePicker();
customDateTimePicker1.Dock = DockStyle.Fill;
this
.Controls.Add(customDateTimePicker1);
customDateTimePicker1.Format = DateTimePickerFormat.Custom;
customDateTimePicker1.FormatProvider += radDateTimePicker1_FormatProvider;
customDateTimePicker1.Value = DateTime.Now;
}
string
radDateTimePicker1_FormatProvider(
object
sender, CustomFormatProviderEventArgs args)
{
// get the required string value here
return
args.CurrentDate.ToShortDateString();
}
}
public
class
CustomDateTimePicker : RadDateTimePicker
{
public
delegate
string
CustomFormatProviderEventHandler(
object
sender, CustomFormatProviderEventArgs date);
public
event
CustomFormatProviderEventHandler FormatProvider;
protected
override
void
OnValueChanged(EventArgs e)
{
base
.OnValueChanged(e);
if
(
this
.Format == DateTimePickerFormat.Custom &&
this
.FormatProvider !=
null
)
{
this
.DateTimePickerElement.TextBoxElement.Text =
this
.FormatProvider(
this
,
new
CustomFormatProviderEventArgs(
this
.Value));
}
}
}
public
class
CustomFormatProviderEventArgs : EventArgs
{
public
DateTime CurrentDate {
get
;
set
; }
public
CustomFormatProviderEventArgs()
{
}
public
CustomFormatProviderEventArgs(DateTime dateTime)
{
this
.CurrentDate = dateTime;
}
}
}
Hope this will help, please let me know if there is anything else i can help you with.
Best Regards,
Emanuel Varga