PowerTools CalendarGrid for Windows Forms 1.0J
DateFormat プロパティ (CalendarCell)
使用例 

このセルの日付書式を取得または設定します。
構文
Public Property DateFormat As String
public string DateFormat {get; set;}

プロパティ値

日付書式を示す System.String 値。既定値は null 参照 (Visual Basicでは Nothing) です。
解説
日付書式が設定されたセルには、Value の代わりに書式設定された日付テキストが表示されます。DateFormatType によって書式タイプを選択できます。
使用例
次のサンプルコードは、DateFormat の設定方法を示します。
private void SetDateFormat()
{
    this.gcCalendarGrid1.CurrentDate = new DateTime(2014, 2, 14);

    CalendarTemplate template = new CalendarTemplate(4, 1, 2, 1);

    // Displays "2月" in Japanese culture.
    // Displays "February" in English culture.
    template.ColumnHeader[0, 0].DateFormat = CalendarDateFormats.Month;
    template.ColumnHeader[0, 0].AutoMergeMode = AutoMergeMode.Horizontal;

    // Displays "金" in Japanese culture.
    // Displays "Fri" in English culture.
    template.ColumnHeader[1, 0].DateFormat = CalendarDateFormats.AbbreviatedDayOfWeek;
    template.ColumnHeader[0, 0].AutoMergeMode = AutoMergeMode.Horizontal;

    // Displays "7" in Japanese culture.
    // Displays "7" in English culture.
    template.RowHeader[0, 0].DateFormat = CalendarDateFormats.WeekNumber;
    template.RowHeader[0, 0].RowSpan = 4;

    // Displays "2014/02/14" in Japanese culture.
    // Displays "2/14/2014" in English culture.
    template.Content[0, 0].DateFormat = CalendarDateFormats.ShortDate;
    template.Content[0, 0].DateFormatType = CalendarDateFormatType.CalendarGrid;

    // Displays "2014/02/14 (先負)" in Japanese culture.
    // Displays "2/14/2014 (先負)" in English culture.
    template.Content[1, 0].DateFormat = "{ShortDate} ({Rokuyou})";
    template.Content[1, 0].DateFormatType = CalendarDateFormatType.CalendarGrid;

    // Displays "2014/2/14" in Japanese culture.
    // Displays "2014/2/14" in English culture.
    template.Content[2, 0].DateFormat = "yyyy/M/d";
    template.Content[2, 0].DateFormatType = CalendarDateFormatType.DotNet;

    // Displays "平成 26/2/14" in Japanese culture.
    // Displays "平成 26/2/14" in English culture.
    template.Content[3, 0].DateFormat = "ggg ee/M/d";
    template.Content[3, 0].DateFormatType = CalendarDateFormatType.InputMan;

    this.gcCalendarGrid1.Template = template;
}
Private Sub SetDateFormat()
    Me.gcCalendarGrid1.CurrentDate = New DateTime(2014, 2, 14)

    Dim template As New CalendarTemplate(4, 1, 2, 1)

    ' Displays "2月" in Japanese culture.
    ' Displays "February" in English culture.
    template.ColumnHeader(0, 0).DateFormat = CalendarDateFormats.Month
    template.ColumnHeader(0, 0).AutoMergeMode = AutoMergeMode.Horizontal

    ' Displays "金" in Japanese culture.
    ' Displays "Fri" in English culture.
    template.ColumnHeader(1, 0).DateFormat = CalendarDateFormats.AbbreviatedDayOfWeek
    template.ColumnHeader(0, 0).AutoMergeMode = AutoMergeMode.Horizontal

    ' Displays "7" in Japanese culture.
    ' Displays "7" in English culture.
    template.RowHeader(0, 0).DateFormat = CalendarDateFormats.WeekNumber
    template.RowHeader(0, 0).RowSpan = 4

    ' Displays "2014/02/14" in Japanese culture.
    ' Displays "2/14/2014" in English culture.
    template.Content(0, 0).DateFormat = CalendarDateFormats.ShortDate
    template.Content(0, 0).DateFormatType = CalendarDateFormatType.CalendarGrid

    ' Displays "2014/02/14 (先負)" in Japanese culture.
    ' Displays "2/14/2014 (先負)" in English culture.
    template.Content(1, 0).DateFormat = "{ShortDate} ({Rokuyou})"
    template.Content(1, 0).DateFormatType = CalendarDateFormatType.CalendarGrid

    ' Displays "2014/2/14" in Japanese culture.
    ' Displays "2014/2/14" in English culture.
    template.Content(2, 0).DateFormat = "yyyy/M/d"
    template.Content(2, 0).DateFormatType = CalendarDateFormatType.DotNet

    ' Displays "平成 26/2/14" in Japanese culture.
    ' Displays "平成 26/2/14" in English culture.
    template.Content(3, 0).DateFormat = "ggg ee/M/d"
    template.Content(3, 0).DateFormatType = CalendarDateFormatType.InputMan

    Me.gcCalendarGrid1.Template = template
End Sub
参照

CalendarCell クラス
CalendarCell メンバ
CalendarDateFormatInfo クラス

 

 


© 2014 GrapeCity inc. All rights reserved.