PowerTools CalendarGrid for Windows Forms 1.0J
六曜
参考:六曜とは?
六曜(ろくよう)は14世紀ごろに中国から日本に伝えられましたが、広く行われるようになったのは幕末以降のことです。時代とともにその名称や順序も変遷していて、現在は、先勝(せんしょう、せんかち、さきかち)、友引(ともびき、ゆういん)、先負(せんぷ、せんぶ、せんまけ、さきまけ)、仏滅(ぶつめつ)、大安(たいあん、だいあん)、赤口(しゃっく、じゃっく、しゃっこう、じゃっこう、せきぐち)となっています(下線は現在多く用いられる読み)。たとえば、1月、7月(旧暦)の1日(朔日)に先勝を当て、以後順に配当していきます。意味の解釈は様々で、どれが正しいという基準はありません。(国会図書館ギャラリー、暦の中のことばより)

CalendarGridで六曜を表示するには、Cell.DateFormatプロパティに"{Rokuyou}"を設定し、Cell.DateFormatTypeプロパティをCalendarGridに設定します。

カレンダーの各日に六曜を表示するには、次のようにコーディングします。

Imports GrapeCity.Win.CalendarGrid

Dim template As CalendarTemplate = gcCalendarGrid1.Template
template.Content.Rows(1).Cells(0).DateFormat = "{Rokuyou}"
template.Content.Rows(1).Cells(0).DateFormatType = CalendarDateFormatType.CalendarGrid
using GrapeCity.Win.CalendarGrid;

var template = gcCalendarGrid1.Template;
template.Content.Rows[1].Cells[0].DateFormat = "{Rokuyou}";
template.Content.Rows[1].Cells[0].DateFormatType = CalendarDateFormatType.CalendarGrid;

特定の日の六曜をコーディングで取得するには、次のように記述します。

Imports GrapeCity.Win.CalendarGrid

Dim today As DateTime = DateTime.Now
Dim rokuyou As String = GcCalendarGrid1.DateFormatInfo.FormatDate(today, "{Rokuyou}", CalendarDateFormatType.CalendarGrid)
Console.WriteLine("{0}の六曜は{1}です。", today.ToShortDateString(), rokuyou)
using GrapeCity.Win.CalendarGrid;

var today = DateTime.Now;
string rokuyou = gcCalendarGrid1.DateFormatInfo.FormatDate(today, "{Rokuyou}", CalendarDateFormatType.CalendarGrid);
Console.WriteLine("{0}の六曜は{1}です。", today.ToShortDateString(), rokuyou);
注意:
CalendarGridで六曜を表示可能な範囲は1960/1/28から2050/1/22までです。

CalendarGrid上で任意の六曜を非表示にするには、次のようにコーディングします。次の例では大安と仏滅以外を非表示にします。

GcCalendarGrid1.DateFormatInfo.RokuyouNames = "大安,,,,,仏滅"
gcCalendarGrid1.DateFormatInfo.RokuyouNames = "大安,,,,,仏滅";
参照

 

 


© 2014 GrapeCity inc. All rights reserved.