This is a migrated thread and some comments may be shown as answers.

Unable to set Display text on DateTimePicker

3 Answers 167 Views
DateTimePicker
This is a migrated thread and some comments may be shown as answers.
Rod Yager
Top achievements
Rank 1
Rod Yager asked on 26 Jun 2012, 04:15 PM
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. ???

Thanks,
Rod
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();

3 Answers, 1 is accepted

Sort by
0
Vladi
Telerik team
answered on 29 Jun 2012, 12:10 PM
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,
Vladi
the Telerik team

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

0
ENRIQUE
Top achievements
Rank 1
answered on 05 May 2020, 08:00 AM

Hi.
I am updating the version of the controls from 2010 to 2020.
The same happens to me with MVVM. But if I change the InputMode to "DatePicker" the control shows data.
In the 2010 version this did not happen and the control showed data with both InputMode.

 

0
Vladimir Stoyanov
Telerik team
answered on 08 May 2020, 06:55 AM

Hello Enrique,

I tested the scenario in a sample project, however the SelectedValue is displayed in the RadDateTimePicker when the InputMode is TimePicker. That is why I am attaching the project that I used for testing purposes. Can you check it out and see how it differs from the setup on your end?

Should you need any further assistance, you can modify it in order to replicate the observed on your end behavior and send it back in a new support ticket (since project files cannot be attached to forum posts). This will allow me to investigate further and better assist you.

Regards,
Vladimir Stoyanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
DateTimePicker
Asked by
Rod Yager
Top achievements
Rank 1
Answers by
Vladi
Telerik team
ENRIQUE
Top achievements
Rank 1
Vladimir Stoyanov
Telerik team
Share this question
or