Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic TimeTable view - scroll position (Read 1878 times)
BenWTS
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Jun 19th, 2008
TimeTable view - scroll position
Aug 7th, 2008 at 3:39pm
Print Post  
I'm trying to ensure that the start of my work time hours is visible when I load up the control or change the work time start hour through code but am having a hard time.

For example, I've setup our use of the control to contain multiple "groups". Each group can specify the work time hours, so Group 1 could be 9-5 and Group 2 could be 4-10. When I switch from group 1 to group 2 I want the scroll to be set in such a way that 4pm is visible.

I've tried using the .EnsureVisible command but it doesn't seem to work well after I change the work time hours for the control.

I could probably try and calculate a value for ScrollPosition directly, but is there a way to determine what the max scroll position is? Because it's also possible for the CellTime to switch when going from Group 1 to Group 2.

Any help would be appreciated.
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: TimeTable view - scroll position
Reply #1 - Aug 8th, 2008 at 7:04am
Print Post  
I am using the EnsureVisible method and it seems to work well. Here is my code:

Code
Select All
calendar1.EnsureVisible(
      calendar1.TimetableSettings.Dates[0] +
      TimeSpan.FromHours(calendar1.TimetableSettings.WorkTimeStartHour)); 


I am getting the first displayed date in the timetable view and then I add the number of hours specified by WorkTimeStartHour to receive the exact date and time of the first cell in the work period.

Another method with similar effect would be, as you suggested, to manually calculate the desired scroll position. Here is a sample code to achieve this:

Code
Select All
long ticks = TimeSpan.FromHours(calendar1.TimetableSettings.WorkTimeStartHour).Ticks -
      TimeSpan.FromMinutes(calendar1.TimetableSettings.StartTime).Ticks;
long cell = calendar1.TimetableSettings.CellTime.Ticks;

int scroll = (int)(ticks / cell);

calendar1.VScrollPos = scroll; 


Meppy
  
Back to top
 
IP Logged
 
BenWTS
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Jun 19th, 2008
Re: TimeTable view - scroll position
Reply #2 - Aug 8th, 2008 at 3:13pm
Print Post  
Thanks again Meppy. The 2nd solution worked for me.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint