| GrapeCity CalendarGrid for Windows Forms 3.0J > CalendarGridの使い方 > InputManCell > GcDateTime型セル > 書式を設定する(CalendarGcDateTimeCellType) > キーワードによる書式設定 (CalendarGcDateTimeCellType) |
CalendarGcDateTimeCellType.FieldsプロパティまたはGcDateTime.Fieldsプロパティのコレクションを通して特定のフィールドにアクセスできます。
日付時刻コントロールでは、キーワードによる書式設定が可能です。
入力書式を設定するには、Fieldsプロパティが参照するDateFieldCollectionクラスのAddRangeメソッドに、入力書式用のキーワードを使用した文字列を設定します。
表示書式を設定するには、DisplayFieldsプロパティが参照するDateDisplayFieldCollectionクラスのAddRangeメソッドに、表示書式用のキーワードを使用した文字列を設定します。
Imports InputManCell = GrapeCity.Win.CalendarGrid.InputMan Dim today As DateTime = DateTime.Today Dim GcDateTimeCellType As New InputManCell.CalendarGcDateTimeCellType() ' フィールドをクリアします。 GcDateTimeCellType.Fields.Clear() GcDateTimeCellType.DisplayFields.Clear() ' キーワードから書式を設定します。 GcDateTimeCellType.Fields.AddRange("yyyy年 MM月 dd日 HH時 mm分 ss秒") GcDateTimeCellType.DisplayFields.AddRange("ggg ee年 MM月 dd日 HH時 mm分 ss秒") GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellType = GcDateTimeCellType GcCalendarGrid1.ScrollIntoView(today)
using InputManCell = GrapeCity.Win.CalendarGrid.InputMan; var today = DateTime.Today; var gcDateTimeCellType = new InputManCell.CalendarGcDateTimeCellType(); // フィールドをクリアします。 gcDateTimeCellType.Fields.Clear(); gcDateTimeCellType.DisplayFields.Clear(); // キーワードから書式を設定します。 gcDateTimeCellType.Fields.AddRange("yyyy年 MM月 dd日 HH時 mm分 ss秒"); gcDateTimeCellType.DisplayFields.AddRange("ggg ee年 MM月 dd日 HH時 mm分 ss秒"); gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellType = gcDateTimeCellType; gcCalendarGrid1.ScrollIntoView(today);
入力書式として使用可能なキーワードは以下のとおりです。
| キーワード | 説明 |
|---|---|
|
g |
年号の頭文字をアルファベットで表示(M、T、S、H、R) |
|
gg |
年号の頭文字を漢字で表示(明、大、昭、平、令) |
|
ggg |
年号の正式名称を漢字で表示(明治、大正、昭和、平成、令和) |
|
e |
和暦年を2桁で表示(先頭に0を付けない) |
|
ee |
和暦年を2桁で表示(先頭に0を付ける) |
|
yy |
年を2桁で表示(先頭に0を付ける) |
|
yyyy |
年を4桁で表示(先頭に0を付ける) |
|
MM |
月を2桁の数字で表示(先頭に0を付ける) |
|
MMM |
月を省略形で表示 |
|
MMMM |
月を正式名称で表示 (DateTimeFormatInfo.MonthNames() で指定された形式) |
|
dd |
日を2桁で表示(先頭に0を付ける) |
|
t |
12時間制で時刻を表示するときに午前(AMDesignatorプロパティで設定)または午後(PMDesignatorプロパティで設定)を表す文字列の最初の1文字を表示 |
|
tt |
12時間制で時刻を表示するときに午前(AMDesignatorプロパティで設定)または午後(PMDesignatorプロパティで設定)を表す文字列を表示 |
|
hh |
時を12時間制で表示(先頭に0を付ける) |
|
HH |
時を24時間制で表示(先頭に0を付ける) |
|
mm |
分を表示(先頭に0を付ける) |
|
ss |
秒を表示(先頭に0を付ける) |
|
\(Chr(92)) |
キーワードをリテラル文字として表示 |
表示書式として使用可能なキーワードは以下のとおりです。
| キーワード | 説明 |
|---|---|
|
A |
紀元後を表す"A.D.(Anno Domini)"を表示 |
|
g |
年号の頭文字をアルファベットで表示(M、T、S、H、R) |
|
gg |
年号の頭文字を漢字で表示(明、大、昭、平、令) |
|
ggg |
年号の正式名称を漢字で表示(明治、大正、昭和、平成、令和) |
|
e |
和暦年を2桁で表示(先頭に0を付けない) |
|
ee |
和暦年を2桁で表示(先頭に0を付ける) |
|
E |
和暦年を2桁で表示し開始年を元と表示(先頭に0を付けない) (例:平成元年) |
|
EE |
和暦年を2桁で表示し開始年を元と表示(先頭に0を付ける) |
|
y |
年を2桁で表示(先頭に0を付けない) |
|
yy |
年を2桁で表示(先頭に0を付ける) |
|
yyy |
年を4桁で表示(先頭に0を付けない) |
|
yyyy |
年を4桁で表示(先頭に0を付ける) |
|
M |
月を2桁の数字で表示(先頭に0を付けない) |
|
MM |
月を2桁の数字で表示(先頭に0を付ける) |
|
MMM |
月を省略形で表示 |
|
MMMM |
月を正式名称で表示 |
|
d |
日を表示(先頭に0を付けない) |
|
dd |
日を表示(先頭に0を付ける) |
|
ddd |
曜日を省略形で表示 |
|
dddd |
曜日を正式名称で表示 |
|
t |
12時間制で時刻を表示するときに午前(AMDesignatorプロパティで設定)または午後(PMDesignatorプロパティで設定)を表す文字列の最初の1文字を表示 |
|
tt |
12時間制で時刻を表示するときに午前(AMDesignatorプロパティで設定)または午後(PMDesignatorプロパティで設定)を表す文字列を表示 |
|
h |
時を12時間制で表示(先頭に0を付けない) |
|
hh |
時を12時間制で表示(先頭に0を付ける) |
|
H |
時を24時間制で表示(先頭に0を付けない) |
|
HH |
時を24時間制で表示(先頭に0を付ける) |
|
m |
分を表示(先頭に0を付けない) |
|
mm |
分を表示(先頭に0を付ける) |
|
s |
秒を表示(先頭に0を付けない) |
|
ss |
秒を表示(先頭に0を付ける) |
|
\(Chr(92)) |
キーワードをリテラル文字として表示 |