The MindFusion Forums
Scheduling and Gantt Components >> Windows Forms >> Sizing calendar
https://mindfusion.eu/Forum/YaBB.pl?num=1489771590

Message started by john6630 on Mar 17th, 2017 at 5:26pm

Title: Sizing calendar
Post by john6630 on Mar 17th, 2017 at 5:26pm
I would like to set the calendar height in time table view to exactly fit the time cells, header and border. Currently if I size the calendar to fit the height of the panel containing the calendar it displays an large cell at the bottom of the calendar. If the panel is smaller, it fits fine with the addition of vertical scroll bar. See the attached image to see what I am talking about.

Thank you,
John
Capture_001.JPG ( 141 KB | 222 Downloads )

Title: Re: Sizing calendar
Post by Meppy on Mar 20th, 2017 at 8:25am
Hi,

You can calculate the total height by multiplying the number of cells by the cell size and adding the height of the header(s).

[code]var settings = calendar.TimetableSettings;
int cellCount = (int)Math.Ceiling((settings.EndTime - settings.StartTime) / settings.CellTime.TotalMinutes);
var headerBounds = calendar.GetElementBounds(CalendarElement.TimetableColumnHeader, 0);
int height = cellCount * settings.CellSize + headerBounds.Height;[/code]

I hope this helps.

Regards,
Meppy

Title: Re: Sizing calendar
Post by john6630 on Mar 20th, 2017 at 11:10pm
Hi Meppy,
That helps. I think my difficulty is in how to set the timetable start and end times for a 24 hour period not starting at midnight. IE 6AM day 1 to 6AM day 2. Can you advise how best to do that?

Thanks,
John

Title: Re: Sizing calendar
Post by Meppy on Mar 21st, 2017 at 8:25am
Hi,

Use the StartTime and EndTime properties of the TimetableSettings class:

[code]calendar.TimetableSettings.StartTime = 360; // 6 AM in minutes
calendar.TimetableSettings.EndTime = 1800; // 6 AM on the following day[/code]
Regards,
Meppy

Title: Re: Sizing calendar
Post by fractal07 on May 12th, 2017 at 11:20am
Hello,
I carefully read you post and I wish your advise to a different calculation. My Timetable is in a form and I would to display the same time range (06:00 to 19:00) whatever is the height of the form.
To be clear: I would always see the range from startTime to endTime without any vertical scrollbar, my calendar have to fit the height of the form, the adjustment will be the cell height. Should I use zoom property?
Kind regards

Title: Re: Sizing calendar
Post by Meppy on May 12th, 2017 at 11:46am
Precisely. Set the UseZoom property and the cell sizes will be automatically calculated so that all cells fit in the visible space:

[code]calendar.TimetableSettings.UseZoom = State.Enabled;
calendar.TimetableSettings.StartTime = 360; // 6 AM in minutes
calendar.TimetableSettings.EndTime = 1140; // 7 PM in minutes[/code]
Regards,
Meppy

Title: Re: Sizing calendar
Post by fractal07 on May 12th, 2017 at 12:07pm
Great, thank you! It avoids me lot of work and calculations!
(documentation is not much verbose on usage of this function...)

The MindFusion Forums » Powered by YaBB 2.6.11!
YaBB Forum Software © 2000-2024. All Rights Reserved.