GrapeCity CalendarGrid for Windows Forms 2.0J
表示する週の数を設定する

週スタイルのカレンダーでは、表示する週の数を変更できます。既定では1週間だけが表示されています。
2週間を表示するには次のようにコーディングします。

Imports GrapeCity.Win.CalendarGrid

Dim weekView As New CalendarWeekView()
weekView.WeekCount = 2
GcCalendarGrid1.CalendarView = weekView
using GrapeCity.Win.CalendarGrid;

var weekView = new CalendarWeekView();
weekView.WeekCount = 2;
gcCalendarGrid1.CalendarView = weekView;

表示されている画面いっぱいに、可能な限り週を表示するには次のようにコーディングします。

Imports GrapeCity.Win.CalendarGrid

Dim weekView As New CalendarWeekView()
GcCalendarGrid1.CalendarView = weekView

Dim calendarHeaderHeight As Integer = GcCalendarGrid1.TitleHeader.Height
Dim headerHeight As Integer = 0
Dim template As CalendarTemplate = GcCalendarGrid1.Template
For i As Integer = 0 To template.ColumnHeader.RowCount - 1
    headerHeight += template.ColumnHeader.Rows(i).Height
Next
                                                                
Dim contentHeight As Integer = 0
For i As Integer = 0 To template.Content.RowCount - 1
    contentHeight += template.Content.Rows(i).Height
Next

Dim freeSpace As Integer = GcCalendarGrid1.ClientRectangle.Height
freeSpace -= calendarHeaderHeight
freeSpace -= headerHeight

Dim weekCount As Integer = 0
If freeSpace > contentHeight Then
    weekCount = freeSpace / contentHeight
End If

weekView.WeekCount = weekCount
using GrapeCity.Win.CalendarGrid;

var weekView = new CalendarWeekView();
gcCalendarGrid1.CalendarView = weekView;

int calendarHeaderHeight = gcCalendarGrid1.TitleHeader.Height;
int headerHeight = 0;
var template = gcCalendarGrid1.Template;
for (int i = 0; i < template.ColumnHeader.RowCount; i++)
{
    headerHeight += template.ColumnHeader.Rows[i].Height;
}

int contentHeight = 0;
for (int i = 0; i < template.Content.RowCount; i++)
{
    contentHeight += template.Content.Rows[i].Height;
}

int freeSpace = gcCalendarGrid1.ClientRectangle.Height;
freeSpace -= calendarHeaderHeight;
freeSpace -= headerHeight;

int weekCount = 0;
if (freeSpace > contentHeight)
{
    weekCount = freeSpace / contentHeight;
}

weekView.WeekCount = weekCount;
参照

 

 


© 2008 GrapeCity inc. All rights reserved.