Print Page | Close Window

Setting Date Selected to Date Other Than Today

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Calendar
Forum Description: Topics Related to Codejock Calendar
URL: http://forum.codejock.com/forum_posts.asp?TID=5325
Printed Date: 03 July 2024 at 5:21am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Setting Date Selected to Date Other Than Today
Posted By: DDJJ
Subject: Setting Date Selected to Date Other Than Today
Date Posted: 19 October 2006 at 4:11pm
Under certain circumstances when our users open the form with our calendar control, we want the first month shown in the DatePicker control to be September 2005 (this month has been pre-populated with events to display to the user).
 
We no not seem to be able to get the DatePicker to have any date selected other than Today when our form loads.  We've been trying variations of the following to get the DatePicker to load with 9/1/2005 selected:
 
DatePicker1.ClearSelection
DatePicker1.EnsureVisible #9/1/2005#
DatePicker1.SelectRange #9/1/2005#, #9/1/2005#
DatePicker1.Select #9/1/2005#
DatePicker1.EnsureVisibleSelection
Nothing seems to work.  We always end up with today being the selected date.  Any ideas why?
 
Thanks, Dan
 



Replies:
Posted By: DDJJ
Date Posted: 19 October 2006 at 4:13pm
Also, the above code DOES get the DatePicker control to show the appropriate months, but the Calendar control always seems to display Today???


Posted By: sserge
Date Posted: 22 October 2006 at 3:58pm
Note that attaching DatePicker to Calendar affects only user's actions. Both controls do have their methods to change selection and active shown period, and you can use those methods to manipulate. Example which can be used on forms loading:

DatePicker1.Select #9/1/2005#
DatePicker1.EnsureVisibleSelection
Calendar1.ActiveView.ShowDay #9/1/2005#
DatePicker1.AttachToCalendar Calendar1


--
WBR,
Serge


Posted By: DDJJ
Date Posted: 23 October 2006 at 11:27am
Thanks Serge.
 
I've tried using variations of your code, with no luck.
 
I can get the form to load with (1) the appropriate day selected in the calendar control, (2) the appropriate months displayed in the data picker control, and (3) with the appropriate days in bold where events exist.
 
Although it looks like 9/1/2005 is already selected (and 9/1/2005 is bold, as it should be), the calendar control doesn't fill until I click on 9/1/2005 in the date picker???  If I check during the Form_Activate event, my code tells me that the "Selected" date is Today???
 
Dan


Posted By: sserge
Date Posted: 24 October 2006 at 3:52am
Well, this looks to be a small bug in calendar. Date Picker should be updated inside AttachToCalendar call. To be fixed.
 
But for now to ensure this update just call AttachToCalendar before setting up Calendar1.ViewType or ShowDay (or change ViewType to ensure that).
 
Example:

DatePicker1.AttachToCalendar Calendar1
 
Calendar1.ViewType = xtpCalendarWeekView
Calendar1.ViewType = xtpCalendarDayView

' Populate method should be used to read data and update calendar
Calendar1.Populate


--
WBR,
Serge



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net