|
-
Aug 18th, 2021, 04:48 AM
#1
Thread Starter
New Member
datetimepicker value is always true
Hi,
I've made a datetimepicker with a checkbox in it. Datetimepicker is intended as a filter - the user enters the date and gets filtered the data for that date. dtp is without binding.
The problem is there, if the datetimepicker checkbox is empty, it still retains the value.
Currently datetimepicker constantly feeds value to the database.
So I thought, is that a validation problem or only the properties, but in my case I added checked = true and showcheckedbox = true also or need to looking somewhere else.
-
Aug 18th, 2021, 04:57 AM
#2
Re: datetimepicker value is always true
The Value property is type DateTime, so of course it always has a value. It's up to you to test the value of the Checked property and then use or don't use the Value property. It's not going to magic it for you.
vb.net Code:
If myDateTimePicker.Checked Then
'Use myDateTimePicker.Value here.
Else
'Don't use myDateTimePicker.Value.
End If
-
Aug 18th, 2021, 07:44 AM
#3
Thread Starter
New Member
Re: datetimepicker value is always true
 Originally Posted by jmcilhinney
The Value property is type DateTime, so of course it always has a value. It's up to you to test the value of the Checked property and then use or don't use the Value property. It's not going to magic it for you.
vb.net Code:
If myDateTimePicker.Checked Then
'Use myDateTimePicker.Value here.
Else
'Don't use myDateTimePicker.Value.
End If
Thanks.
Just figured it out, gave value as endDate and it worked.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|