DatePicker - checked property?
Messages   Related Types
This message was discovered on ASPFriends.com 'winforms-cs' list.


Jeff Woodie
I'm trying to use the DatePicker control for an ExpirationDate value for my
application, and the ExpirationDate is optional. So if the user unchecks
the box, then I want to record an empty value for this field in the
database. Now, I've avoided any NULL/DateTime value issues by assigning the
empty value to "01/01/1900", so that works fine.

The issue I'm having is in trying to set the .Checked property of this
DatePicker control to false. In general the ExpirationDate field will NOT
have a value assigned to it, so I want this control to be UN-checked by
default. Problem is, it doesn't want to stay unchecked.

I've set the property ( .Checked )in the Properties window to false. I've
set the property via code in a number of places (form constructor, methods,
etc.) and whenever the form comes up, the checkbox is always checked.
Granted this is not the most mission-critical code I'll ever write, but
since this field is not going to be used most of the time, this will an
annoyance to almost every user of the system.

So what am I doing wrong?

I've set:
dateExpiration.Checked = false
dateExpiration.MaxDate = "12/31/2023"
dateExpiration.MinDate = Today
dateExpiration.ShowCheckBox = true
dateExpiration.Value = Today

Does giving the .Value property a value automatically set the .Checked to
true? That seems unnatural. If so, is there a way to set this to EMPTY or
NULL? I get Invalid Property Value when I try something like that.

Seems like a strange problem. I've also checked the Windows Form Designer
code to make sure that the .Checked property is set properly in there (isn't
out of sync with what's in the Property window) and that's all good. Any
help with this problem would be appreciated.

Thanks,

Jeff Woodie

Reply to this message...
 
    
Scott Berry
This is a bug (the same bug that Joe (JFuentes) pointed out earlier). A
workaround is to set Checked =3D false last. To later set the date,
toggle the Checked property:
            dateExpiration.Value =3D
dateExpiration.Value.AddDays(1);
            dateExpiration.Checked ^=3D true;
            dateExpiration.Checked ^=3D true;

    -Scott

This posting is provided "AS IS" with no warranties, and confers no
rights.

-----Original Message-----
From: Jeff Woodie [mailto:Click here to reveal e-mail address]=20
Sent: Tuesday, June 11, 2002 12:46 PM
To: winforms-cs
Subject: [winforms-cs] DatePicker - checked property?

I'm trying to use the DatePicker control for an ExpirationDate value for
my
application, and the ExpirationDate is optional. So if the user
unchecks
the box, then I want to record an empty value for this field in the
database. Now, I've avoided any NULL/DateTime value issues by assigning
the
empty value to "01/01/1900", so that works fine.

The issue I'm having is in trying to set the .Checked property of this
DatePicker control to false. In general the ExpirationDate field will
NOT
have a value assigned to it, so I want this control to be UN-checked by
default. Problem is, it doesn't want to stay unchecked. =20

I've set the property ( .Checked )in the Properties window to false.
I've
set the property via code in a number of places (form constructor,
methods,
etc.) and whenever the form comes up, the checkbox is always checked.
Granted this is not the most mission-critical code I'll ever write, but
since this field is not going to be used most of the time, this will an
annoyance to almost every user of the system.

So what am I doing wrong?

I've set:
dateExpiration.Checked =3D false
dateExpiration.MaxDate =3D "12/31/2023"
dateExpiration.MinDate =3D Today
dateExpiration.ShowCheckBox =3D true
dateExpiration.Value =3D Today

Does giving the .Value property a value automatically set the .Checked
to
true? That seems unnatural. If so, is there a way to set this to EMPTY
or
NULL? I get Invalid Property Value when I try something like that.

Seems like a strange problem. I've also checked the Windows Form
Designer
code to make sure that the .Checked property is set properly in there
(isn't
out of sync with what's in the Property window) and that's all good.
Any
help with this problem would be appreciated.

Thanks,

Jeff Woodie

| [winforms-cs] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/asplists/winforms-cs.asp =3D JOIN/QUIT

Reply to this message...
 
 
System.DateTime




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com