PowerTools PlusPak for Windows Forms 8.0J
Add(HolidayStyle,CalendarNote,Boolean) メソッド
使用例 

メモに関連付けられた休日スタイルを示す HolidayStyle 値。
コレクションに追加する CalendarNote
Text の代わりに休日名をメモに表示するかどうかを示す System.Boolean 値。
CalendarNote をコレクションに追加し、そのメモを指定した休日スタイルに関連付けます。
構文
Public Overloads Sub Add( _
   ByVal holidayStyle As HolidayStyle, _
   ByVal note As CalendarNote, _
   ByVal showHolidayName As Boolean _
) 

パラメータ

holidayStyle
メモに関連付けられた休日スタイルを示す HolidayStyle 値。
note
コレクションに追加する CalendarNote
showHolidayName
Text の代わりに休日名をメモに表示するかどうかを示す System.Boolean 値。
使用例

次のサンプルコードは、CalendarNoteHolidayStyle に関連付ける方法を示します。また、NoteStyle を使用してメモの外観を設定する方法も示します。

private void CreateCalendarWithNoteStyle()
{
    // Create a GcCalendar.
    GcCalendar gcCalendar1 = new GcCalendar();
    gcCalendar1.Size = new Size(500, 500);
    gcCalendar1.CalendarType = CalendarType.MonthDay;

    // Add 3 holiday styles for Sunday, Monday, and Saturday in each month.
    HolidayStyle holidayStyle1 = new HolidayStyle("holidayStyle1");
    holidayStyle1.Holidays.Add(new DayOfWeekHoliday("Sunday", MonthFlags.All, DayOfWeekInMonthFlags.All, DayOfWeekFlags.Sunday));
    HolidayStyle holidayStyle2 = new HolidayStyle("holidayStyle2");
    holidayStyle2.Holidays.Add(new DayOfWeekHoliday("Monday", MonthFlags.All, DayOfWeekInMonthFlags.All, DayOfWeekFlags.Monday));
    HolidayStyle holidayStyle3 = new HolidayStyle("holidayStyle3");
    holidayStyle3.Holidays.Add(new DayOfWeekHoliday("Saturday", MonthFlags.All, DayOfWeekInMonthFlags.All, DayOfWeekFlags.Saturday));
    gcCalendar1.HolidayStyles.Add(holidayStyle1.Name, holidayStyle1);
    gcCalendar1.HolidayStyles.Add(holidayStyle2.Name, holidayStyle2);
    gcCalendar1.HolidayStyles.Add(holidayStyle3.Name, holidayStyle3);
    gcCalendar1.ActiveHolidayStyles = new string[] { "holidayStyle1", "holidayStyle2", "holidayStyle3" };

    // Allow the notes to show in calendar.
    gcCalendar1.ShowNotes = true;

    // Set the default style for notes.
    gcCalendar1.DefaultNoteStyle.BackColor = Color.LightBlue;
    gcCalendar1.DefaultNoteStyle.ForeColor = Color.DarkBlue;

    // Create 2 named note style and add them to calendar.
    NoteStyle style1 = new NoteStyle("style1");
    style1.BackColor = Color.LightGreen;
    style1.ForeColor = Color.DarkGreen;
    NoteStyle style2 = new NoteStyle("style2");
    style2.BackColor = Color.Pink;
    style2.ForeColor = Color.Brown;
    gcCalendar1.NoteStyles.Add(style1);
    gcCalendar1.NoteStyles.Add(style2);

    // Add 3 notes for the holiday styles. The notes will display the  holiday names and use different note styles.
    gcCalendar1.Notes.Add("holidayStyle1", new CalendarNote(null, null, NoteDisplayMode.Text, "style1"), true);
    gcCalendar1.Notes.Add("holidayStyle2", new CalendarNote(null, null, NoteDisplayMode.Text, "style2"), true);
    gcCalendar1.Notes.Add("holidayStyle3", new CalendarNote(null, null, NoteDisplayMode.Text), true);

    this.Controls.Add(gcCalendar1);
}
Private Sub CreateCalendarWithNoteStyle()
    ' Create a GcCalendar.
    Dim gcCalendar1 As New GcCalendar()
    gcCalendar1.Size = New Size(500, 500)
    gcCalendar1.CalendarType = CalendarType.MonthDay

    ' Add 3 holiday styles for Sunday, Monday, and Saturday in each month.
    Dim holidayStyle1 As New HolidayStyle("holidayStyle1")
    holidayStyle1.Holidays.Add(New DayOfWeekHoliday("Sunday", MonthFlags.All, DayOfWeekInMonthFlags.All, DayOfWeekFlags.Sunday))
    Dim holidayStyle2 = New HolidayStyle("holidayStyle2")
    holidayStyle2.Holidays.Add(New DayOfWeekHoliday("Monday", MonthFlags.All, DayOfWeekInMonthFlags.All, DayOfWeekFlags.Monday))
    Dim holidayStyle3 = New HolidayStyle("holidayStyle3")
    holidayStyle3.Holidays.Add(New DayOfWeekHoliday("Saturday", MonthFlags.All, DayOfWeekInMonthFlags.All, DayOfWeekFlags.Saturday))
    gcCalendar1.HolidayStyles.Add(holidayStyle1.Name, holidayStyle1)
    gcCalendar1.HolidayStyles.Add(holidayStyle2.Name, holidayStyle2)
    gcCalendar1.HolidayStyles.Add(holidayStyle3.Name, holidayStyle3)
    gcCalendar1.ActiveHolidayStyles = New String() {"holidayStyle1", "holidayStyle2", "holidayStyle3"}

    ' Allow the notes to show in calendar.
    gcCalendar1.ShowNotes = True

    ' Set the default style for notes.
    gcCalendar1.DefaultNoteStyle.BackColor = Color.LightBlue
    gcCalendar1.DefaultNoteStyle.ForeColor = Color.DarkBlue

    ' Create 2 named note style and add them to calendar.
    Dim style1 = New NoteStyle("style1")
    style1.BackColor = Color.LightGreen
    style1.ForeColor = Color.DarkGreen
    Dim style2 = New NoteStyle("style2")
    style2.BackColor = Color.Pink
    style2.ForeColor = Color.Brown
    gcCalendar1.NoteStyles.Add(style1)
    gcCalendar1.NoteStyles.Add(style2)

    ' Add 3 notes for the holiday styles. The notes will display the  holiday names and use different note styles.
    gcCalendar1.Notes.Add("holidayStyle1", New CalendarNote(Nothing, Nothing, NoteDisplayMode.Text, "style1"), True)
    gcCalendar1.Notes.Add("holidayStyle2", New CalendarNote(Nothing, Nothing, NoteDisplayMode.Text, "style2"), True)
    gcCalendar1.Notes.Add("holidayStyle3", New CalendarNote(Nothing, Nothing, NoteDisplayMode.Text), True)

    Me.Controls.Add(gcCalendar1)
End Sub
プラットフォーム

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

参照

CalendarNoteCollection クラス
CalendarNoteCollection メンバ
オーバーロード一覧

Send Feedback