现在的位置: 首页 > 综合 > 正文

关于DateTimePicker控件Show None属性的问题

2018年02月08日 ⁄ 综合 ⁄ 共 1179字 ⁄ 字号 评论关闭

       利用Show None属性可以设置是否选择日期,内含一个CheckBox,使用CheckBox 属性能够指定控件是否返回日期。缺省情况下,CheckBox  的值为False,并且控件总是返回一个日期。如果CheckBox属性设为True,那么在控件日期和时间左边的编辑部分中将出现一个小的复选框。如果这个复选框没有被选中,那么Value属性返回一个空值。如果选中了这个复选框,那么控件通过Value属性返回当前显示日期。   

        可以通过以下方式获得CheckBox是否选中的状态:
        CString strYear  = _T("");
        CString strMonth = _T("");
       CString strDay   = _T("");
       CTime timeTime;   
        DWORD   dwResult   =   m_ctrValidTime.GetTime(timeTime);
        if   (dwResult   ==   GDT_VALID)  
        {  
              strYear.Format("%d", timeTime.GetYear());
              strMonth.Format("%d", timeTime.GetMonth());
              strDay.Format("%d", timeTime.GetDay());
              strYear = strYear.Right(2);
              if ( strMonth.GetLength() == 1 )
              {
                     strMonth = _T("0") + strMonth;
              }
             if ( strDay.GetLength() == 1 )
            {
                   strDay = _T("0") + strDay;
            }
            m_strValidTime = strYear + strMonth + strDay;  
            m_strValidTime.TrimLeft();
            m_strValidTime.TrimRight();   
             AfxMessageBox("你选中了checkbox时间是" + strValidTime );  
        }  
        else  
        {  
              AfxMessageBox(_T("你没有选中了checkbox!"));  
        }  

 

 

更多技术文章请参看施昌权的个人网站: http://www.joyvc.cn

 

 

抱歉!评论已关闭.