Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 84751

RadDateTimePicker sets time to midnight

$
0
0
Hello Jayalaxmi,

Thank you for writing.
 

You can create a derivative of RadDateTimePicker implementing the custom behavior in it. Then, use the custom control where it necessary:
public class MyDateTimePicker : RadDateTimePicker
{
    public override string ThemeClassName 
    {
        get
        {
            return typeof(RadDateTimePicker).FullName; 
        }
    }
     
    protected override void CreateChildItems(Telerik.WinControls.RadElement parent)
    {
        base.CreateChildItems(parent);
        RadDateTimePickerElement element = this.DateTimePickerElement;
        RadDateTimePickerCalendar calendarBehavior = element.GetCurrentBehavior() as RadDateTimePickerCalendar;
        calendarBehavior.PopupControl.Opened += new EventHandler(PopupControl_Opened);
        calendarBehavior.PopupControl.Closed += new RadPopupClosedEventHandler(PopupControl_Closed);
    }
 
    private DateTime time;
 
    void PopupControl_Closed(object sender, RadPopupClosedEventArgs args)
    {
        DateTime date = this.Value.Date;
        this.Value = new DateTime(date.Year, date.Month, date.Day, this.time.Hour, this.time.Minute, this.time.Second);
    }
 
    void PopupControl_Opened(object sender, EventArgs e)
    {
        this.time = this.Value;
    }
}

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.

Viewing all articles
Browse latest Browse all 84751

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>