Nullable CDateTimeCtrl?

Hi, all:

I have a datetime fiels visit_date on my dialog which currently using
CDateTimeCtrl for use to pick the date that they visit, but the visit
date should allow null which the CdateTimeCtrl does not support, what
is the best way to implement this?

I am thinking using a masked CEdit ctrl for user to enter date /delete
date, then put a button besidethe textbox so user can click this
button to shoiw the calendar if they want choose date from the
CDateTimeCtrl?

Or are any better implementations out there already, please point me
to the hyperlinks.

thanks
-rockdale
0
3/24/2008 2:58:55 PM
vc.mfc 33608 articles. 0 followers. Follow

6 Replies
736 Views

Similar Articles

[PageSpeed] 20

On Mon, 24 Mar 2008 07:58:55 -0700 (PDT), rockdale
<rockdale.green@gmail.com> wrote:

>Hi, all:
>
>I have a datetime fiels visit_date on my dialog which currently using
>CDateTimeCtrl for use to pick the date that they visit, but the visit
>date should allow null which the CdateTimeCtrl does not support, what
>is the best way to implement this?
>
>I am thinking using a masked CEdit ctrl for user to enter date /delete
>date, then put a button besidethe textbox so user can click this
>button to shoiw the calendar if they want choose date from the
>CDateTimeCtrl?
>
>Or are any better implementations out there already, please point me
>to the hyperlinks.

You can hide the current value with SetFormat(" "). To restore the default 
format, SetFormat(0). This works great for showing a blank control, when
the control is disabled, but if you want to show a blank, enabled control,
you'll have to figure out which messages to handle in order to restore the
date/time display at the right moment. 

-- 
Doug Harrison
Visual C++ MVP
0
dsh (2498)
3/24/2008 3:50:05 PM
The first time I can use SetFormat("") to hide Today's date when I
initDialog, Then the user can
pick a date from the CDateTimeCtrl, but what if they try to delete/
empty the date they picked before? This part I do not know how. add a
button say "clear"
also, How could I know the DateTime is picked by the user or is the
underline datetime for SetFormat(""), or should I set a special date
so that I know the user did not pick a date?

thanks again

On Mar 24, 1:16=A0pm, "Sheng Jiang[MVP]"
<sheng_ji...@hotmail.com.discuss> wrote:
> use DTS_SHOWNONE
>
> --
> Sheng Jiang
> Microsoft MVP in VC++"rockdale" <rockdale.gr...@gmail.com> wrote in messag=
e
>
> news:47df4c4f-dd81-40f8-b6ae-6ca495aae7d0@s50g2000hsb.googlegroups.com...
>
>
>
> > Hi, all:
>
> > I have a datetime fiels visit_date on my dialog which currently using
> > CDateTimeCtrl for use to pick the date that they visit, but the visit
> > date should allow null which the CdateTimeCtrl does not support, what
> > is the best way to implement this?
>
> > I am thinking using a masked CEdit ctrl for user to enter date /delete
> > date, then put a button besidethe textbox so user can click this
> > button to shoiw the calendar if they want choose date from the
> > CDateTimeCtrl?
>
> > Or are any better implementations out there already, please point me
> > to the hyperlinks.
>
> > thanks
> > -rockdale- Hide quoted text -
>
> - Show quoted text -

0
3/24/2008 4:40:30 PM
use DTS_SHOWNONE

-- 
Sheng Jiang
Microsoft MVP in VC++
"rockdale" <rockdale.green@gmail.com> wrote in message
news:47df4c4f-dd81-40f8-b6ae-6ca495aae7d0@s50g2000hsb.googlegroups.com...
> Hi, all:
>
> I have a datetime fiels visit_date on my dialog which currently using
> CDateTimeCtrl for use to pick the date that they visit, but the visit
> date should allow null which the CdateTimeCtrl does not support, what
> is the best way to implement this?
>
> I am thinking using a masked CEdit ctrl for user to enter date /delete
> date, then put a button besidethe textbox so user can click this
> button to shoiw the calendar if they want choose date from the
> CDateTimeCtrl?
>
> Or are any better implementations out there already, please point me
> to the hyperlinks.
>
> thanks
> -rockdale


0
sheng_jiang (305)
3/24/2008 5:16:23 PM
I am not suggesting changing the formating. I am suggesting the DTS_SHOWNONE
style.
Use SetTime/GetTime to get/set the time.A null time has a COleDateTime::null
status.

-- 
Sheng Jiang
Microsoft MVP in VC++
"rockdale" <rockdale.green@gmail.com> wrote in message
news:f187b421-065f-4332-9b80-33ed2dac0a61@m3g2000hsc.googlegroups.com...
The first time I can use SetFormat("") to hide Today's date when I
initDialog, Then the user can
pick a date from the CDateTimeCtrl, but what if they try to delete/
empty the date they picked before? This part I do not know how. add a
button say "clear"
also, How could I know the DateTime is picked by the user or is the
underline datetime for SetFormat(""), or should I set a special date
so that I know the user did not pick a date?

thanks again

On Mar 24, 1:16 pm, "Sheng Jiang[MVP]"
<sheng_ji...@hotmail.com.discuss> wrote:
> use DTS_SHOWNONE
>
> --
> Sheng Jiang
> Microsoft MVP in VC++"rockdale" <rockdale.gr...@gmail.com> wrote in
message
>
> news:47df4c4f-dd81-40f8-b6ae-6ca495aae7d0@s50g2000hsb.googlegroups.com...
>
>
>
> > Hi, all:
>
> > I have a datetime fiels visit_date on my dialog which currently using
> > CDateTimeCtrl for use to pick the date that they visit, but the visit
> > date should allow null which the CdateTimeCtrl does not support, what
> > is the best way to implement this?
>
> > I am thinking using a masked CEdit ctrl for user to enter date /delete
> > date, then put a button besidethe textbox so user can click this
> > button to shoiw the calendar if they want choose date from the
> > CDateTimeCtrl?
>
> > Or are any better implementations out there already, please point me
> > to the hyperlinks.
>
> > thanks
> > -rockdale- Hide quoted text -
>
> - Show quoted text -


0
sheng_jiang (305)
3/26/2008 3:47:38 PM
On Wed, 26 Mar 2008 09:47:38 -0600, "Sheng Jiang[MVP]"
<sheng_jiang@hotmail.com.discuss> wrote:

>I am not suggesting changing the formating. I am suggesting the DTS_SHOWNONE
>style.
>
>Use SetTime/GetTime to get/set the time.A null time has a COleDateTime::null
>status.

Last time I looked, DTS_SHOWNONE added a checkbox inside the control, and
when unchecked, simply grayed the text of the control. I never could get
the control to display nothing at all using DTS_SHOWNONE. The only way I
found was the SetFormat method I posted earlier.

-- 
Doug Harrison
Visual C++ MVP
0
dsh (2498)
3/26/2008 4:51:53 PM
The op wants to
1 pick the date that they visit,
2 allow null which he thinks the CDateTimeCtrl does not support
I just point out CDateTimeCtrl does support null values.

I agree changing the formating will look nicer, but the feedback from data
entry people is that masked editbox makes input faster.

-- 
Sheng Jiang
Microsoft MVP in VC++
"Doug Harrison [MVP]" <dsh@mvps.org> wrote in message
news:20vku39l4nu2vd42uh4rn5pd59osoc4nnd@4ax.com...
> On Wed, 26 Mar 2008 09:47:38 -0600, "Sheng Jiang[MVP]"
> <sheng_jiang@hotmail.com.discuss> wrote:
>
> >I am not suggesting changing the formating. I am suggesting the
DTS_SHOWNONE
> >style.
> >
> >Use SetTime/GetTime to get/set the time.A null time has a
COleDateTime::null
> >status.
>
> Last time I looked, DTS_SHOWNONE added a checkbox inside the control, and
> when unchecked, simply grayed the text of the control. I never could get
> the control to display nothing at all using DTS_SHOWNONE. The only way I
> found was the SetFormat method I posted earlier.
>
> -- 
> Doug Harrison
> Visual C++ MVP


0
sheng_jiang (305)
3/26/2008 6:07:04 PM
Reply:

Similar Artilces:

CDateTimeCtrl #4
How do I let a user blank out a date after it has already been added and saved. The control doesn't allow me to blank out a date. ...

Nullable CDateTimeCtrl?
Hi, all: I have a datetime fiels visit_date on my dialog which currently using CDateTimeCtrl for use to pick the date that they visit, but the visit date should allow null which the CdateTimeCtrl does not support, what is the best way to implement this? I am thinking using a masked CEdit ctrl for user to enter date /delete date, then put a button besidethe textbox so user can click this button to shoiw the calendar if they want choose date from the CDateTimeCtrl? Or are any better implementations out there already, please point me to the hyperlinks. thanks -rockdale On Mon, 24 Mar 2008 07...

CDateTimeCtrl #10
Im using Visual C++ 6.0. My problem concerns a datetime picker. When i change the date and change the time subsequently and remove focus from datetime picker it forgets the time or it rolls back to the previous time. I want the time to remain. Any solution for this problem? when you set focus to the DTP control and try to change date or time after that and the change focus from the DTP then both date and time roll back to the privious values. "bilisa" wrote: > Im using Visual C++ 6.0. > My problem concerns a datetime picker. When i change the date and change the > ...

Nullable Parameter in a Report issue
The error message is: The property ‘nullable’ of report parameter ‘CRM_Locale’ is set to false. I have had this error before during our initial installation, but do not remember how it was fixed. we just performed a reinstall of the whole CRM system in order to correct some performance issues between CRM and Reporting Services. I know others have encountered this same issue. Anybody remember the solution? Browse to your SRS website (http://servername/reports) and navigate to the report in question. View the report's properties and click Parameters on the left. Place a checkmark i...

CRecordset and nullable types
Hello all. I have a CRecordset-derived class that interacts with a database. This particular table has a nullable foreign key. So, when the value is not assigned it must be null (otherwise it would break the relationship). So the question is, in my DoFieldExchange method, how do I tell the CRecordset that the field is null? Regards, FG. hi, why cant you check the value of foreign key in DoFieldExchange method? if it have not be assigned value , you may assign it a value of null. pFX->SetFieldType(CDaoFieldExchange::outputColumn); DFX_Text(pFX, "Name", m_strName); DFX_Shor...

Nullable Foreign key constriants
I am just trying to get a general consenus from SQL experts on whether or not nullable Foreign Key contrainsts are a key database design or a poor database design. Comments and opinions on this is appreciatable. Thanks, You should let foriegn keys be NULL when the business model requires that it can be NULL and not allow NULLs when the business model requires that a non null entry be made in the foreign key. For instance, for most companies, you can't have an order unless that order is going to a customer. So you would have a customer id in the Orders table, and...

Custom CDateTimeCtrl notification messages
I wrote class CMyTimePicker : public CDateTimeCtrl {...} It has a handler for DateTime Change message: ON_NOTIFY_REFLECT(DTN_DATETIMECHANGE, OnDatetimechange) .... void CMyTimePicker::OnDatetimechange(NMHDR* pNMHDR, LRESULT* pResult) { //do smth *pResult = 0; } I also need to notify parent dialog that this message occured. How to do this? Regular handler in parent dialog does not resond if I overrride it in my derived class: ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATETIMEPICKER1, OnDatetimechangeDatetimepicker1) void CMyDlg::OnDatetimechangeDatetimepicker1(NMHDR* pNMHDR, LRESULT* pResult) { ...

Setting PK as not nullable via code
Hi I need to run through all table in the db and set the primary key in each as not nullable. How can I achieve this via code? Many Thanks Regards "John" <info@nospam.infovis.co.uk> wrote in message news:ub2ljw0xKHA.5480@TK2MSFTNGP06.phx.gbl... > I need to run through all table in the db and set the primary key in each > as not nullable. How can I achieve this via code? No need: if a field is (in) the primary key, it cannot be null. It is actually possible to set the Required property of the field to Yes using DAO code if you need to. Refer ...

CDateTimeCtrl #5
How do I allow a user to blank out a date when a date has already been entered into it and saved? "William Gower" <w_gower@hotmail.com> wrote in message news:uJQQYzHiDHA.2420@TK2MSFTNGP10.phx.gbl... > How do I allow a user to blank out a date when a date has already been > entered into it and saved? See if this kb article helps at all... http://support.microsoft.com/default.aspx?scid=kb;en-us;238077 Jeff... ...

alter column
A variable length column need to change its nullability property: alter table T alter column c varchar(5000) not null; The length of 5000 is not changed. Changing a column's nullability to disallow NULLs, should imply a scan of the table and then a change of the metadata. The actual data should not be modified. That seems reasonable, and that’s how we have understood it from written sources on the subject. However, using Profiler, it turns out that its execution requires a lot of resources. It seems like the table is read twice and written once. Why? If the above obse...

Casting to Nullable Types
I can't get the following line of code to work. Any idea how to do this? int? result = subCategoryRow["RevisionNumber"].Equals(DBNull.Value) ? null : (int?) subCategoryRow["RevisionNumber"]; I get an invalid cast exception. Regards, Fred Chateau Fred Chateau wrote: > I can't get the following line of code to work. Any idea how to do this? > > int? result = subCategoryRow["RevisionNumber"].Equals(DBNull.Value) ? > null : (int?) subCategoryRow["RevisionNumber"]; >...

Eliminate nullable types when serializing...
I'm doing a little R&D. I've got a simple object: public class AccountNullable { private int? _AcctID; private string _AcctName; [XmlElementAttribute(IsNullable = true)] public int? AcctID { get { return _AcctID; } set { _AcctID = value; } } public string AcctName { get { return _AcctName; } set { _AcctName = value; } } } I want to be able to serialize this object and have any property that is null be left out of the resulting xml. For example, th...

Changet Font Size of CDateTimeCtrl?
Hi, I have a CDateTimeCtrl and I'm trying to change the font size of the Date Time Control (not the font size of the Calender Control), the SetFont() function does not seem to work. If there anything special I need to do with CDateTimeCtrl to change the font size? Thanks. WJ >I have a CDateTimeCtrl and I'm trying to change the font size of the Date >Time Control (not the font size of the Calender Control), the SetFont() >function does not seem to work. When you say SetFont doesn't seem to work, what have you tried, and what was the result? The usual problem pe...

CDateTimeCtrl #3
Can a CDateTimeCtrl be initialized as blank and how do you handle it if a user doesn't know the date and wants to leave the field blank? ...

CDateTimeCtrl specific time intervall ???
Hi! I am using VC++ .NET 2003 and MFC. within my app I am uinsg a CDateTimeCtrl to allow the user to select a time-intervall (HH:MM) I would like to modify the selection of the minutes so that the user can select any hour-value but can only select 10 minute intervalls. how can I achieve this ? any help with this would be greatly appreciated, thanx in advance! regards, Hans On Sat, 29 Mar 2008 10:36:48 -0700 (PDT), hpesata <hpesata@gmx.at> wrote: >Hi! > >I am using VC++ .NET 2003 and MFC. >within my app I am uinsg a CDateTimeCtrl to allow the user to select a >time-int...

XML Serialization with nullable values
Hello, I have been reading a lot of pages and I cannot seem to find a easy solution for my problem... I have to deserialize (and serialize) a file which looks like this: ************** <record> <field1>data1</field1> <field2 nil="true"></field2> </record> ************** That is it... no XML header, no namespace, no comments, etc... I created a class like this: ************** public class record() { public string field1 {get; set; } [XmlElement(IsNullable=true)] public int? field2 {get; set; } } *************...

Milliseconds in CDateTimeCtrl
Hi, can anybody plz let me know if there's any way we can specify milliseconds using CDateTimeCtrl control i.e; in the format 00:00:00:000 where the last '000' specify the milliseconds ... thanx a lot K ...

Typing to Nullable (Of Date) vs typing to Date
This is just an example of the crux of the problem: CType(CObj("11/09/2009"), Date) Returns date object as expected. CType(CObj("11/09/2009"), Nullable(of Date)) In QuickWatch returns the string. At runtime crashes out with invalid Cast. Can someone explain the different behaviour to me please? I don't see why one works and one doesn't. Also assuming I have a gridview returning IOrderedDictionary, how do I convert blanks strings to nothing and non-blank string to date? Do I have to resort to IIF? Given that Nullable(of Date) can't cope with di...

the attribute "nullable" is not supported in convert excel to xml
in excel 2003 when i map xml schema file(xsd) with attribute that set nullable = "true" ex. <xsd:element name="PREV_APPRAISED_VAL" type="xsd:double" nullable="true" minOccurs="0"/> then message returns "the attribute "nullable" is not supported on the declaration xsd:elemement" ...

Problem with CDateTimeCtrl and DateTimePicker
Hi all, I have a with CDateTimeCtrl. Here is my code: CDateTimeCtrl *fgt_date = (CDateTimeCtrl *) GetDlgItem(IDC_FGT_DATE), *ship_date = (CDateTimeCtrl *) GetDlgItem(IDC_SHIP_DATE); fgt_date->GetTime(date); vbu_record.set_fgt_date(date); ship_date->GetTime(date); vbu_record.set_ship_date(date); After the last statement is executed, the vc++ debug library assert triggered: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) Does anyone has any idea what I have done wrong? -HS Phuah Well the last statement has something to do with vbu_record. What is that??? Ali R. "Hon Seng Phuah&...

Dataset diffgram doesn't set xsi:nil for nullable elements
I found a post about this exact issue: http://groups.google.com/group/microsoft.public.dotnet.xml/browse_thread/thread/1dfeb38170cb0b1/ea073666a4035bd5?lnk=st&q=decimal+parse+error+loading+dataset&rnum=6&hl=en#ea073666a4035bd5 but it only shows how to correct the issue manually, not whether it is a known bug. My situation is slightly different only in that the xml data and schema I have are coming directly from the DataSet using: DataSet.GetXml() DataSet.GetXmlSchema() I have a nullable numeric database column: MONTHS I want to be able to actualy set the value to null in the da...

Defaulting a CDateTimeCtrl to none
I am using the CDateTimeCtrl with the allow none thus I get the check mark and the user has to turn it off. How do I default the control to no check mark to start with and the user has to turn it on? Simply call SetTime(). "William Gower" <w_gower@hotmail.com> wrote in message news:eQvSJEa4DHA.2384@TK2MSFTNGP10.phx.gbl... > I am using the CDateTimeCtrl with the allow none thus I get the check mark > and the user has to turn it off. How do I default the control to no check > mark to start with and the user has to turn it on? > > ...

CDateTimeCtrl
I have called the SetTime() member on a CDateTimeCtrl control in a dialog passing it a LPSYSTEMTIME parameter but it fails to set the value in the control. I checked to see what error code was being returned and it was 0. Therefore I checked to see if the dialog was visible at the time I made the call and it isn't. Therefore my assumption is that this control requires the dialog to be visible prior to setting the value of the date, right? I went into my CPropertyPage::OnSetActive() method to try and set the value of the date/time control there with no luck. So I've tried OnSetActiv...

Tab in CDateTimeCtrl
If I insert a date/time picker control (CDateTimeCtrl) into a dialog, specifying a time format, the tab key does not jump from field to field within the control but rather jumps to the next control in the dialog. Yet, in the operating system dialog to set the system date and time (underneath the analog clock in Date and Time Properties), the tab key does jump from hours to minutes to seconds. How can I duplicate the operating system behavior in my own dialog? I don't see information in CDateTimeCtrl documentation to getting/setting the time field that is selected. >If I insert a da...

Empty CDateTimeCtrl ?
I needed to have date-time controls which would be initialized to either blank or with the date in a COleDateTime object, based upon whether on not it the COleDateTime or a 'valid date'. At the same time, however, I couldn't use the 'allow none' option for the control, as it didn't really hide the initial date (somewhere in 1899), and the popup CMonthCalCtrl would start in 1899: a hassle for the user. So, I used a conditional formatting of the control to SetFormat("' '"), if the value was zero, but needed to (1) restore it to the original form...