帮助DateTime Picker [英] Help with DateTime Picker

查看:110
本文介绍了帮助DateTime Picker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我正在使用日期时控制选择器。



是否有更简单的方法从所选日期减去或添加任意天数,或者我是否需要进行手动计算并设定日期?





我们将非常感谢任何帮助。



提前致谢。

Hello,

I am using the date-time control picker.

Is there an easier way to subtract or add any number of days from the selected date or will I have to do a manual calculation and set the date?


Any help will be greatly appreciated.

Thanks in advance.

推荐答案

如果您使用MFC,那么添加天数的最简单方法是使用COleDateTime()类作为DateTime选择器的日期以及COleDateTimeSpan类来添加/减去天数:

If you use MFC then the simplest way to add days is to use COleDateTime() class for the dates from the DateTime picker together with COleDateTimeSpan class to add/subtract the days:
CDateTimeCtrl *pDt = (CDateTimeCtrl*)GetDlgItem(IDC_DATEPICKER1);
COleDateTime dt1;
pDt->GetTime(dt1);
COleDateTimeSpan Day(1, 0, 0, 0);
COleDateTimeSpan Days2(2, 0, 0, 0);
COleDateTime tomorrow = dt1 + Day;
COleDateTime beforeYesterday = dt1 - Days2;


这篇关于帮助DateTime Picker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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