Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Go to today (Read 2223 times)
SimonL
YaBB Newbies
*
Offline



Posts: 36
Joined: Aug 11th, 2006
Go to today
Mar 2nd, 2007 at 11:27am
Print Post  
We're using your control in our app to display the bookings of hotel rooms. Therefore we have the control in resource view mode. Hotel rooms down the y-axis and dates acrros the x-axis. If the user has scrolled months or years in the future or past, is there a way to bring them back to today.

I saw the following code in another thread but I don't think this works in resource view mode

       '' Calculate the timespan between the starting date in the calendar and the date we want to scroll to
Code
Select All
	  'Dim span As TimeSpan = DateTime.Today - BookingsView.Date

	  '' Calulate the row containing the specified date, considering that each row contains 7 days
	  'Dim col As Integer = CInt(span.TotalDays / 25)

	  ''Scroll the calendar
	  'BookingsView.ScrollPosition = New Point(col, BookingsView.ScrollPosition.Y)
 



Any suggestions ?

Thanks,
Simon
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Go to today
Reply #1 - Mar 2nd, 2007 at 12:16pm
Print Post  
Indeed, calculating the appropriate scroll position in a resource view is way more complex, because it is based on the scroll step interval and the time unit of the bottommost timeline. Filtering is also to be taken into consideration if it is toggled on.

However the method EnsureVisible enables you to 'scroll' to any date or item currently contained within the view. Here is a code which will 'scroll' to today:

Code
Select All
calendar.EnsureVisible(DateTime.Today); 



Once again, this method only works if the targeted date or item is already contained somewhere within the control. The method simply adjusts the value of the scrollbar. It cannot change the start or end date of the contained time interval.

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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Go to today
Reply #2 - Mar 2nd, 2007 at 12:26pm
Print Post  
I'm sorry that the example code is in C#. I saw too late you are using VB.NET. Here is the code in VB.NET:

Code
Select All
calendar.EnsureVisible(DateTime.Today) 



Out of curiosity, why do you divide to 25 in your example code? If the ResourceView.ScrollStep is set to 1 day and the bottommost timeline's TimeUnit is set to TimeUnit.Day, I reckon you should use the span.TotaDays as a X position of the scroller.

Meppy
  
Back to top
 
IP Logged
 
SimonL
YaBB Newbies
*
Offline



Posts: 36
Joined: Aug 11th, 2006
Re: Go to today
Reply #3 - Mar 2nd, 2007 at 12:37pm
Print Post  
Thanks Meppy, exactly what I wanted. I was using 25 because that was the number of day columns I display in the calendar. It was just a guess.

I much prefer your solution, one line of code always works for me Smiley

Regards,
Simon
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint