|
-
Jul 15th, 2007, 10:40 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [2005] Set DatePickerControl Value
I have a date stored in a variable (of type date). It has the month, day, and year. Is there one line of code that will put that date into a DateTimePicker control? I've tried .Value and a couple of others but I couldn't do it. Or do I have to set each part (month, day, year) individually?
-
Jul 16th, 2007, 12:04 AM
#2
Thread Starter
Hyperactive Member
Re: [2005] Set DatePickerControl Value
I wouldn't have thought it, but trial and error suggests that .Text is the right property to set. Strange.
Is there something else I should use instead?
-
Jul 16th, 2007, 02:21 AM
#3
Re: [2005] Set DatePickerControl Value
The Text property is type String. The Value property is type Date. If you have a variable of type Date then you can, and should, assign it directly to the Value property. There is no reason that that should not work. As you have chosen not to provide any details of what happened, which makes it all but impossible for us to diagnose the issue, that's about all I can say. If you "couldn't do it" then you must have got an error message. If we are not provided with that error message then how are we to help fix it?
Furthermore, you should absolutely never be setting the Text property of a DateTimePicker and you should very rarely be getting it. Value is the main property of interest where the DateTimePicker control is concerned.
-
Jul 16th, 2007, 11:07 AM
#4
Thread Starter
Hyperactive Member
Re: [2005] Set DatePickerControl Value
This first one works, the 2nd one does nothing (that I can see)...
vb Code:
dtpDateAssigned(index).Text = CStr(Assignment(index, c).DateAssigned)
dtpDateAssigned(index).Value = Assignment(index, c).DateAssigned
-
Jul 16th, 2007, 11:17 AM
#5
Re: [2005] Set DatePickerControl Value
So, is your question answered?
-
Jul 16th, 2007, 11:24 AM
#6
Thread Starter
Hyperactive Member
Re: [2005] Set DatePickerControl Value
If I'm supposed to use the .Value property, then no, the question is not answered. I'm setting the DateTimePicker to a date but it's not responding in any visible way. When I use the .Text property, it changes as expected.
-
Jul 16th, 2007, 11:40 AM
#7
Re: [2005] Set DatePickerControl Value
Ok. What is the code that you currently have and is it generating an error?
-
Jul 16th, 2007, 11:44 AM
#8
Thread Starter
Hyperactive Member
Re: [2005] Set DatePickerControl Value
I found the problem and fixed it.
-
Jul 16th, 2007, 11:46 AM
#9
Re: [RESOLVED] [2005] Set DatePickerControl Value
What was it (your solution may help someone else)?
-
Jul 16th, 2007, 11:51 AM
#10
Thread Starter
Hyperactive Member
Re: [RESOLVED] [2005] Set DatePickerControl Value
The code was called from a DataGridView CurrentCellChanged event. If the CurrentCell was in column(0) of the grid which was the name column, there was no date. The code was trying to put a nonexistent date into the DatePickerControl. Any of the other columns worked fine because they had dates.
Also, after my initial post, I had changed when the code got fired and I did THAT wrong. So the code that set the DateTimePicker's date was never getting executed (after I edited the code). That made it look like nothing was happening.
-
Jul 16th, 2007, 08:19 PM
#11
Re: [RESOLVED] [2005] Set DatePickerControl Value
This is why you really need to give a complete explanation of what you're doing and exactly waht happens when you do it. Hurried, partial explanations don't give us a clear picture of the situation so diagnosing the issue is often difficult or impossible.
-
Jul 16th, 2007, 11:29 PM
#12
Thread Starter
Hyperactive Member
Re: [RESOLVED] [2005] Set DatePickerControl Value
Sorry suh! I'll try to be mo bettah! I won't do dat no mo.
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
|