代码中设置的DateTimePicker值不会反映在屏幕上 [英] DateTimePicker value set in code is not reflected on screen

查看:68
本文介绍了代码中设置的DateTimePicker值不会反映在屏幕上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有ComboBox和DateTimePicker的表单。用户可以使用日期选择器选择日期或使用组合框选择学期名称。如果他们使用组合框选择术语,则应更新日期选择器以显示所选术语的
开始日期。


在组合框的SelectedIndexChanged事件中为所选术语计算相关日期,并将dateTimePicker的值设置为该日期。调试显示datePicker.Value具有新日期,但它没有显示在表单上。我有
尝试在dateTimePicker和Form上都包含一个Refresh,但是没有任何东西可以显示正确的结果。


我没有做什么?有什么想法?




Mike VE

解决方案


>>调试显示datePicker.Value具有新日期,但未在表单上显示。


您是否将DateTimePicker设置如下?如果是,请删除此。

 dateTimePicker1.Format = DateTimePickerFormat.Custom; 
dateTimePicker1.CustomFormat =" " ;;

此外,没有代码,这纯粹是猜测工作。请提供您的代码,以便我们为您提供帮助,


最好的问候,


Bob



I have a form with a ComboBox and a DateTimePicker. The user can use the date-picker to select a date or use the combo-box to select the name of a school term. If they selct the term using the combo box then the date-picker should be updated to show the start date of the chosen term.

In the SelectedIndexChanged event of the combo box the relevant date is calculated for the selected term and the dateTimePicker's Value is set to that date. Debugging shows that the datePicker.Value has the new date but it does not show on the form. I have tried including a Refresh on both the dateTimePicker and the Form but nothing gets it to show the right result.

What am I failing to do? Any ideas?


Mike VE

解决方案

Hi,

>>Debugging shows that the datePicker.Value has the new date but it does not show on the form.

Do you set the DateTimePicker as below? If yes, please delete this.

    dateTimePicker1.Format = DateTimePickerFormat.Custom;
    dateTimePicker1.CustomFormat = " ";

In addition, without code it is purely guess work. Please provide your code so we can assist you,

Best Regards,

Bob


这篇关于代码中设置的DateTimePicker值不会反映在屏幕上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆