GcDateTime型セルの祝日設定に「山の日」を追加したい
対象製品
SPREAD for Windows Forms 7.0J
詳細
2016年から、8月11日に「山の日」が国民の祝日として施行されます。
カレンダーコントロールやドロップダウンカレンダーの休日設定に2016年以降の8月11日を追加するには、ForceHolidayオブジェクトを使用して、特定の年にだけ適用される休日を生成します。
◎サンプルコード(VB)
◎サンプルコード(C#)
2016年以降に「山の日」が追加された祝日定義ファイルはこちら からダウンロードできます。
カレンダーコントロールやドロップダウンカレンダーの休日設定に2016年以降の8月11日を追加するには、ForceHolidayオブジェクトを使用して、特定の年にだけ適用される休日を生成します。
◎サンプルコード(VB)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' 休日スタイルの設定
Dim nationalHoliday As New GrapeCity.Win.Spread.InputMan.CellType.HolidayStyle()
nationalHoliday.Name = "国民の祝日"
nationalHoliday.SubStyle = New GrapeCity.Win.Spread.InputMan.CellType.SubStyle(Color.White, Color.Red, True, False)
' 2016年から2099年まで、山の日を設定
For i As Integer = 2016 To 2099
nationalHoliday.Holidays.Add(New GrapeCity.Win.Spread.InputMan.CellType.ForceHoliday("山の日", DateTime.Parse(i.ToString() + "/8/11")))
Next
' 休日スタイルをコレクションに追加してGcDateTime型セルのカレンダーに反映
Dim gdtcell As New GrapeCity.Win.Spread.InputMan.CellType.GcDateTimeCellType()
gdtcell.DropDownCalendar.HolidayStyles.Add("国民の祝日", nationalHoliday)
gdtcell.DropDownCalendar.ActiveHolidayStyles = New String() {"国民の祝日"}
FpSpread1.ActiveSheet.Columns(0).CellType = gdtcell
End Sub
' 休日スタイルの設定
Dim nationalHoliday As New GrapeCity.Win.Spread.InputMan.CellType.HolidayStyle()
nationalHoliday.Name = "国民の祝日"
nationalHoliday.SubStyle = New GrapeCity.Win.Spread.InputMan.CellType.SubStyle(Color.White, Color.Red, True, False)
' 2016年から2099年まで、山の日を設定
For i As Integer = 2016 To 2099
nationalHoliday.Holidays.Add(New GrapeCity.Win.Spread.InputMan.CellType.ForceHoliday("山の日", DateTime.Parse(i.ToString() + "/8/11")))
Next
' 休日スタイルをコレクションに追加してGcDateTime型セルのカレンダーに反映
Dim gdtcell As New GrapeCity.Win.Spread.InputMan.CellType.GcDateTimeCellType()
gdtcell.DropDownCalendar.HolidayStyles.Add("国民の祝日", nationalHoliday)
gdtcell.DropDownCalendar.ActiveHolidayStyles = New String() {"国民の祝日"}
FpSpread1.ActiveSheet.Columns(0).CellType = gdtcell
End Sub
◎サンプルコード(C#)
private void Form1_Load(object sender, EventArgs e)
{
// 休日スタイルの設定
GrapeCity.Win.Spread.InputMan.CellType.HolidayStyle nationalHoliday = new GrapeCity.Win.Spread.InputMan.CellType.HolidayStyle();
nationalHoliday.Name = "国民の祝日";
nationalHoliday.SubStyle = new GrapeCity.Win.Spread.InputMan.CellType.SubStyle(Color.White, Color.Red, true, false);
// 2016年から2099年まで、山の日を設定
for (int i = 2016; i < 2099; i++)
{
nationalHoliday.Holidays.Add(new GrapeCity.Win.Spread.InputMan.CellType.ForceHoliday("山の日", DateTime.Parse(i.ToString() + "/8/11")));
}
// 休日スタイルをコレクションに追加してGcDateTime型セルのカレンダーに反映
GrapeCity.Win.Spread.InputMan.CellType.GcDateTimeCellType gdtcell = new GrapeCity.Win.Spread.InputMan.CellType.GcDateTimeCellType();
gdtcell.DropDownCalendar.HolidayStyles.Add("国民の祝日", nationalHoliday);
gdtcell.DropDownCalendar.ActiveHolidayStyles = new string[] { "国民の祝日" };
fpSpread1.ActiveSheet.Columns[0].CellType = gdtcell;
}
{
// 休日スタイルの設定
GrapeCity.Win.Spread.InputMan.CellType.HolidayStyle nationalHoliday = new GrapeCity.Win.Spread.InputMan.CellType.HolidayStyle();
nationalHoliday.Name = "国民の祝日";
nationalHoliday.SubStyle = new GrapeCity.Win.Spread.InputMan.CellType.SubStyle(Color.White, Color.Red, true, false);
// 2016年から2099年まで、山の日を設定
for (int i = 2016; i < 2099; i++)
{
nationalHoliday.Holidays.Add(new GrapeCity.Win.Spread.InputMan.CellType.ForceHoliday("山の日", DateTime.Parse(i.ToString() + "/8/11")));
}
// 休日スタイルをコレクションに追加してGcDateTime型セルのカレンダーに反映
GrapeCity.Win.Spread.InputMan.CellType.GcDateTimeCellType gdtcell = new GrapeCity.Win.Spread.InputMan.CellType.GcDateTimeCellType();
gdtcell.DropDownCalendar.HolidayStyles.Add("国民の祝日", nationalHoliday);
gdtcell.DropDownCalendar.ActiveHolidayStyles = new string[] { "国民の祝日" };
fpSpread1.ActiveSheet.Columns[0].CellType = gdtcell;
}
2016年以降に「山の日」が追加された祝日定義ファイルはこちら からダウンロードできます。
キーワード
セル型