• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

的DateTimePicker默认值防止呢

用户头像
it1352
帮助1

问题说明

事实:

    • 我有2个选项卡一个TabControl,每个选项卡有2个的DateTimePicker
    • 在Load事件中,我将所有的DTPS的价值。
    • 所有DTPS对真正的设置ShowCheckBoxes并检查虚假设置。
    • 当我执行程序,在第一个选项卡的DTPS都OK,但是当我检查第二个选项卡上DTPS,它们显示当前时间,不是我的负载事件中设置的时间。
  • I have a TabControl with 2 Tabs, Each tab has 2 DateTimePicker.
  • In the Load event, I set the value of all the DTPs.
  • All DTPs have ShowCheckBoxes set on true AND Checked set on false.
  • When I Execute the program, The DTPs in first tab are OK, but when I check the DTPs on second tab, they show current time, not the time I set on the load event.

为什么出现这种情况?我怎样才能避免呢?

Why this happen? How can I avoid it?

正确答案

#1

我的丑的解决方法这个问题,包括上设置活动选项卡中的DTP的驻留前改变它的值,这样的事情:

My ugly workaround to this issue, consists on set active the tab in which the DTP's reside before changing its values, something like this:

DateTime dat1 = DateTime.Today;
DateTime dat2 = dat1.AddDays(1).AddSeconds(-1);

dtpCreatedStart.Value = dat1;
dtpCreatedEnd.Value = dat2;
tbc.SelectTab(1);
dtpModifiedStart.Value = dat1;
dtpModifiedEnd.Value = dat2;
tbc.SelectTab(0);

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcffihf
系列文章
更多 icon
同类精品
更多 icon
继续加载