Unable to set Display text on DateTimePicker

2 posts, 0 answers
  1. Rod Yager
    Rod Yager avatar
    79 posts
    Member since:
    May 2010

    Posted 26 Jun 2012 Link to this post

    I am trying to set the value property in code on the DateTimePicker (Input mode is Time Picker). It looks like the value is being set properly but I never see anything displayed in the UI. I have tried to set the RadDateTimePicker.DateTimeText and that doesn't seem to work either. ???

    RadDateTimePicker dayEndTimePicker = new RadDateTimePicker();
                dayEndTimePicker.InputMode = Telerik.Windows.Controls.InputMode.TimePicker;
                dayEndTimePicker.MinWidth = 75.0;
                dayEndTimePicker.MaxWidth = 75.0;
                dayEndTimePicker.SelectionChanged += new SelectionChangedEventHandler(dayEndTimePicker_SelectionChanged);
                string endTime = GetScreenSettingValue("DayEndTime", "18:00:00", false);
                string[] endTimeSplit = endTime.Split(new Char[] { ':' });
                dayEndTimePicker.SelectedValue = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, Convert.ToInt32(endTimeSplit[0]), Convert.ToInt32(endTimeSplit[1]), Convert.ToInt32(endTimeSplit[2]));
                dayEndTimePicker.DateTimeText = dayEndTimePicker.SelectedValue.Value.ToShortTimeString();
  2. Vladi
    Vladi avatar
    749 posts

    Posted 29 Jun 2012 Link to this post

    Hello Rod,

    I tried to reproduce the issue but couldn't, here is a sample code that represents how to declare a RadDateTimePicker with SelectedValue from the code behind:

    RadDateTimePicker radDateTimePicker = new RadDateTimePicker()
        InputMode = Telerik.Windows.Controls.InputMode.TimePicker,
        SelectedValue= new DateTime(2012, 6, 29, 14, 20, 0, 0)

    Hope this helps.

    All the best,
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top