PowerTools CalendarGrid for Windows Forms 1.0J
日付書式を設定する(テンプレート)

テンプレート上のセルごとに日付書式を設定できます。ここでは、コードでテンプレート上のセルに日付書式を設定する方法を説明します。
日付書式の詳細については、「日付の書式」を参照してください。


任意のセルに日付書式を設定する

セルに日付書式を設定するには、CalendarCell.DateFormatTypeプロパティで日付書式のタイプを設定し、DateFormatTypeプロパティで指定した日付書式タイプに属する日付書式をCalendarCell.DateFormatプロパティで設定します。

次のコードでは、コンテンツセクションの1行1列目に"yyyy/MM/dd"形式で表示する日付書式を設定します。

Imports GrapeCity.Win.CalendarGrid

Dim template As New CalendarTemplate()

' テンプレートの行数、列数を設定します。
template.ColumnCount = 2
template.RowCount = 2

' 日付書式タイプを設定します。
template.Content.Rows(0).Cells(0).DateFormatType = CalendarDateFormatType.DotNet
' 日付書式を設定します。
template.Content.Rows(0).Cells(0).DateFormat = "D"

GcCalendarGrid1.Template = template
using GrapeCity.Win.CalendarGrid;

CalendarTemplate template = new CalendarTemplate();

// テンプレートの行数、列数を設定します。
template.ColumnCount = 2;
template.RowCount = 2;

// 日付書式タイプを設定します。
template.Content.Rows[0].Cells[0].DateFormatType = CalendarDateFormatType.DotNet;
// 日付書式を設定します。
template.Content.Rows[0].Cells[0].DateFormat = "D";

gcCalendarGrid1.Template = template;


和暦を表示する

DateFormatTypeプロパティにInputManを設定すると和暦を表示できます。また、和暦をどのように表示するかについては、DateFormatプロパティの設定値で決まります。

次のコードでは、年号の正式名称を漢字で表示します。

Imports GrapeCity.Win.CalendarGrid

Dim template As New CalendarTemplate()

template.Content.Rows(0).Cells(0).DateFormatType = CalendarDateFormatType.InputMan
' 年号の正式名称を漢字で表示します。
template.Content.Rows(0).Cells(0).DateFormat = "ggg"

GcCalendarGrid1.Template = template
using GrapeCity.Win.CalendarGrid;

CalendarTemplate template = new CalendarTemplate();

template.Content.Rows[0].Cells[0].DateFormatType = CalendarDateFormatType.InputMan;
// 年号の正式名称を漢字で表示します。
template.Content.Rows[0].Cells[0].DateFormat = "ggg";

gcCalendarGrid1.Template = template;


和暦年号を独自に定義する

CaledanrGridでは、和暦表示の年号をアプリケーション構成ファイルにより独自に定義することができます。

和暦年号の設定方法については、「和暦」を参照してください。


参照

 

 


© 2014 GrapeCity inc. All rights reserved.