Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Newbie timetable question (Read 5261 times)
john6630
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 74
Joined: Sep 20th, 2010
Newbie timetable question
Oct 5th, 2010 at 4:16am
Print Post  
I am impressed and a bit overwhelmed with the power and flexibility of your controls.

What I want to do is have a timetable view for one production day with time on the vertical scale in 10 minute increments and each column representing a resource (piece of production equipment;up to 20 on the plant floor).

I will use the control unbound. That is, I will read the schedule from my database into a datatable and create the appointments manually.

Do you have any sample code like this. The samples in the download did not seem to fit my need. But if there is one I over looked, please let me know which one.

I will also want to show a time table view for a single resource across multiple days.

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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Newbie timetable question
Reply #1 - Oct 5th, 2010 at 6:33am
Print Post  
Hi,

Here is the sample code (along with some comments), which will help you achieve your goals:

Code
Select All
// Switch to timetable
calendar1.CurrentView = CalendarView.Timetable;

// Add resources
for (int i = 0; i < 20; i++)
{
	Resource resource = new Resource();
	resource.Name = string.Format("Resource #{0}", i);
	calendar1.Schedule.Resources.Add(resource);
	calendar1.Resources.Add(resource);

	// Note: The resources are added to both Schedule.Resources and
	// Calendar.Resources collections. The first collection should
	// contain all resources in the schedule. The second collection
	// contains a subset of all resources, which are selected to group by.
	// In the above case all resources are selected for grouping
}

// Enable grouping by the resources added above
calendar1.GroupType = GroupType.GroupByResources;

// Specify the number of columns to be visible at the same time
calendar1.TimetableSettings.VisibleColumns = 5; // (or all 20?)

// Set 10-minute time increments
calendar1.TimetableSettings.CellTime = TimeSpan.FromMinutes(10);

// Change the theme?
calendar1.Theme = ThemeType.Vista; 


Quote:
I will also want to show a time table view for a single resource across multiple days.

To modify the resources you group by, simply modify the contents of the Calendar.Resources collection. The following code groups only by the 6th resource
Code
Select All
calendar1.Resources.Clear();
calendar1.Resources.Add(calendar1.Schedule.Resources[5]); 


To add more dates to display in the Timetable, do the following:
Code
Select All
calendar1.TimetableSettings.Dates.Add(DateTime.Today.AddDays(1));
calendar1.TimetableSettings.Dates.Add(DateTime.Today.AddDays(2)); 


Let me know if this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
john6630
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 74
Joined: Sep 20th, 2010
Re: Newbie timetable question
Reply #2 - Oct 5th, 2010 at 1:40pm
Print Post  
Hi Meppy,
Thanks for the great response. And so quick. I am going to enjoy working with your products. I will try this out now and ask more questions.

John
  
Back to top
 
IP Logged
 
john6630
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 74
Joined: Sep 20th, 2010
Re: Newbie timetable question
Reply #3 - Oct 6th, 2010 at 3:22am
Print Post  
I have another question. I set the item's FillColor, TextColor, HeaderTextColor and LineColor based on the status of the item. When the user clicks on the item, these are replaced by the underlying style (I assume) and are not restored until the user clicks somewhere else on the calendar. How can I force the item to revert to the style settings I set (the colors) after I handle the click item?

I tried changing focus to another control on the form but the item style did not restore to my colors.

TIA,
John
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Newbie timetable question
Reply #4 - Oct 6th, 2010 at 6:15am
Print Post  
When he user clicks on the item, the item becomes selected. When the item is selected, its appearance is governed by another style, namely SelectedStyle. You have to adjust the values of this style accordingly for when the item is selected. In addition, if ItemSettings.UseExtendedStyles is set to Enabled, the item will use two additional styles when it is pointed with the mouse and when it is pointed and selected at the same time - PointedStyle and PointedSelectedStyle respectively.

You could also prevent item selection by handling the Calendar.ItemSelecting event, but this way the users won't be able to modify the item interactively.

Let me know if this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
john6630
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 74
Joined: Sep 20th, 2010
Re: Newbie timetable question
Reply #5 - Oct 6th, 2010 at 1:57pm
Print Post  
Hi Meepy,
That was very useful. I wonder, can I deselect the item. For example, setting a selected index  = -1 or such? I want to allow the user to click on the item, I will detect that action, some code will execute and then I want the item displayed as if not selected.

Hope that makes sense.

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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Newbie timetable question
Reply #6 - Oct 6th, 2010 at 3:04pm
Print Post  
First, handle the Calendar.ItemClick event and in the event handler execute the corresponding action. Then, handle the Calendar.ItemSelecting event and set the Confirm property of the accompanying event argument to false to prevent the item from being selected.

Let me know if this works.

Regards,
Meppy
  
Back to top
 
IP Logged
 
john6630
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 74
Joined: Sep 20th, 2010
Re: Newbie timetable question
Reply #7 - Oct 6th, 2010 at 3:10pm
Print Post  
Yes, that works perfectly. And thank you for such fast and excellent support!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint