Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Positioning screen on a particular day (Read 2469 times)
Arny
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Aug 22nd, 2006
Positioning screen on a particular day
Aug 24th, 2006 at 5:05am
Print Post  
I have initialized the calender with the following date range:

cal1.Date = new DateTime(1960, 1, 1, 0, 0, 0);
cal1.EndDate = new DateTime(2020, 12, 31, 23, 59, 0);

So I can view dates from years 1960 through 2020.

How can I position the view so that a particular date is in view (such as Today)? When the calender displays initially in WeekRange view it has a slide bar with it positioned at the top i.e. at the start of the range. I need to choose which days in the range are displayed.
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Positioning screen on a particular day
Reply #1 - Aug 24th, 2006 at 5:31am
Print Post  
Try out the following code:

Code
Select All
// Calculate the timespan between the starting date in the calendar and the date we want to scroll to
TimeSpan span = DateTime.Today - cal1.Date;

// Calulate the row containing the specified date, considering that each row contains 7 days
int row = (int)(span.TotalDays / 7);

// Scroll the calendar
cal1.ScrollPosition = new Point(cal1.ScrollPosition.X, row); 



Meppy
  
Back to top
 
IP Logged
 
Arny
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Aug 22nd, 2006
Re: Positioning screen on a particular day
Reply #2 - Aug 24th, 2006 at 11:48am
Print Post  
Thanks Meppy. Your code didn't work but a bit of trial and error gave me this which does work. Thanks

Code
Select All
		// Calculate the timespan between the starting date in the calendar and the date we want to scroll to
		TimeSpan span = DateTime.Today - calendar1.Date;

		// Calculate the row containing the specified date, considering that each row contains 7 days
		int row = (int)(span.TotalDays / 7);

		// Scroll the calendar
		calendar1.VScrollPos = row;  

  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Positioning screen on a particular day
Reply #3 - Aug 24th, 2006 at 1:13pm
Print Post  
I am glad to know you figured that out, fellow. Cheesy

Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint