休日を設定してもカレンダーに表示されません
対象製品
CalendarGrid for Windows Forms 1.0J
詳細
カレンダーに設定した休日(または祝日)を表示するには、以下の設定が必要です。
Imports GrapeCity.Win.CalendarGrid
' 休日を設定します。
GcCalendarGrid1.Holidays.Add(New DateTime(2014, 1, 1), "元日")
' テンプレートを設定します。
Dim template As New CalendarTemplate()
template.RowHeaderColumnCount = 1
template.ColumnCount = 1
template.ColumnHeaderRowCount = 1
template.RowCount = 2
template.RowHeader.Columns(0).Width = 30
' 日付書式のタイプを設定します。
template.Content.Rows(1).Cells(0).DateFormatType = CalendarDateFormatType.CalendarGrid
' 休日の名前を表示するように日付書式を設定します。
template.Content.Rows(1).Cells(0).DateFormat = "{HolidayName}"
' 休日のスタイルが定義された条件付きセルスタイルの名前を設定します。
template.Content.Rows(1).Cells(0).CellStyleName = "defaultStyle"
GcCalendarGrid1.Template = template
GcCalendarGrid1.ScrollIntoView(New DateTime(2014, 1, 1))
[C#]
using GrapeCity.Win.CalendarGrid;
// 休日を設定します。
gcCalendarGrid1.Holidays.Add(new DateTime(2014, 1, 1), "元日");
// テンプレートを設定します。
CalendarTemplate template = new CalendarTemplate();
template.RowHeaderColumnCount = 1;
template.ColumnCount = 1;
template.ColumnHeaderRowCount = 1;
template.RowCount = 2;
template.RowHeader.Columns[0].Width = 30;
// 日付書式のタイプを設定します。
template.Content.Rows[1].Cells[0].DateFormatType = CalendarDateFormatType.CalendarGrid;
// 休日の名前を表示するように日付書式を設定します。
template.Content.Rows[1].Cells[0].DateFormat = "{HolidayName}";
// 休日のスタイルが定義された条件付きセルスタイルの名前を設定します。
template.Content.Rows[1].Cells[0].CellStyleName = "defaultStyle";
gcCalendarGrid1.Template = template;
gcCalendarGrid1.ScrollIntoView(new DateTime(2014, 1, 1));
-
セルの日付書式に休日名を設定する。
条件付きスタイルに休日のスタイルを設定する。
セルのスタイル名に、休日のスタイルを設定した条件付きスタイルの名前を設定する。
Imports GrapeCity.Win.CalendarGrid
' 休日を設定します。
GcCalendarGrid1.Holidays.Add(New DateTime(2014, 1, 1), "元日")
' テンプレートを設定します。
Dim template As New CalendarTemplate()
template.RowHeaderColumnCount = 1
template.ColumnCount = 1
template.ColumnHeaderRowCount = 1
template.RowCount = 2
template.RowHeader.Columns(0).Width = 30
' 日付書式のタイプを設定します。
template.Content.Rows(1).Cells(0).DateFormatType = CalendarDateFormatType.CalendarGrid
' 休日の名前を表示するように日付書式を設定します。
template.Content.Rows(1).Cells(0).DateFormat = "{HolidayName}"
' 休日のスタイルが定義された条件付きセルスタイルの名前を設定します。
template.Content.Rows(1).Cells(0).CellStyleName = "defaultStyle"
GcCalendarGrid1.Template = template
GcCalendarGrid1.ScrollIntoView(New DateTime(2014, 1, 1))
[C#]
using GrapeCity.Win.CalendarGrid;
// 休日を設定します。
gcCalendarGrid1.Holidays.Add(new DateTime(2014, 1, 1), "元日");
// テンプレートを設定します。
CalendarTemplate template = new CalendarTemplate();
template.RowHeaderColumnCount = 1;
template.ColumnCount = 1;
template.ColumnHeaderRowCount = 1;
template.RowCount = 2;
template.RowHeader.Columns[0].Width = 30;
// 日付書式のタイプを設定します。
template.Content.Rows[1].Cells[0].DateFormatType = CalendarDateFormatType.CalendarGrid;
// 休日の名前を表示するように日付書式を設定します。
template.Content.Rows[1].Cells[0].DateFormat = "{HolidayName}";
// 休日のスタイルが定義された条件付きセルスタイルの名前を設定します。
template.Content.Rows[1].Cells[0].CellStyleName = "defaultStyle";
gcCalendarGrid1.Template = template;
gcCalendarGrid1.ScrollIntoView(new DateTime(2014, 1, 1));