作成日: 2022/03/14 最終更新日: 2022/03/30
文書種別
使用方法
詳細
CalendarGridはテンプレートで定義した1日のレイアウトを繰り返し表示するため、基本的には日付ごとのレイアウトはすべて同じになります。
ただし、実行時に特定の日付とセルの位置を指定して任意のセル型を配置することができます。
次のサンプルコードでは、テンプレートでButton型セルを設定されてるセルに、本日の日付だけTextBox型セルを配置しています。
[Visual Basic]
Imports GrapeCity.Win.CalendarGrid
' テンプレートを設定します。
Dim template As New CalendarTemplate()
template.RowHeaderColumnCount = 1
template.ColumnCount = 1
template.ColumnHeaderRowCount = 1
template.RowCount = 2
template.RowHeader.Columns(0).Width = 30
' Button型セルを作成します。
Dim buttonCellType As New CalendarButtonCellType()
' テンプレートにButton型セルを配置します。
template.Content.Rows(0).Cells(0).DateFormatType = CalendarDateFormatType.DotNet
template.Content.Rows(0).Cells(0).DateFormat = "d"
template.Content.Rows(1).Cells(0).CellType = buttonCellType.Clone()
template.Content.Rows(1).Cells(0).Value = "ボタン"
GcCalendarGrid1.Template = template
Dim today = DateTime.Today
' TextBox型セルを作成します。
Dim textBoxCellType = New CalendarTextBoxCellType()
' 本日の日付にTextBox型セルを設定します。
GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellType = textBoxCellType
GcCalendarGrid1.Content(today).Rows(1).Cells(0).Value = "テキスト"
[C#]
using GrapeCity.Win.CalendarGrid;
// テンプレートを設定します。
CalendarTemplate template = new CalendarTemplate();
template.RowHeaderColumnCount = 1;
template.ColumnCount = 1;
template.ColumnHeaderRowCount = 1;
template.RowCount = 2;
template.RowHeader.Columns[0].Width = 30;
// Button型セルを作成します。
CalendarButtonCellType buttonCellType = new CalendarButtonCellType();
// テンプレートにButton型セルを配置します。
template.Content.Rows[0].Cells[0].DateFormatType = CalendarDateFormatType.DotNet;
template.Content.Rows[0].Cells[0].DateFormat = "d";
template.Content.Rows[1].Cells[0].CellType = buttonCellType.Clone();
template.Content.Rows[1].Cells[0].Value = "ボタン";
gcCalendarGrid1.Template = template;
var today = DateTime.Today;
// TextBox型セルを作成します。
CalendarTextBoxCellType textBoxCellType = new CalendarTextBoxCellType();
//本日の日付にTextBox型セルを設定します。
gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellType = textBoxCellType;
gcCalendarGrid1.Content[today].Rows[1].Cells[0].Value = "テキスト";
ただし、実行時に特定の日付とセルの位置を指定して任意のセル型を配置することができます。
次のサンプルコードでは、テンプレートでButton型セルを設定されてるセルに、本日の日付だけTextBox型セルを配置しています。
[Visual Basic]
Imports GrapeCity.Win.CalendarGrid
' テンプレートを設定します。
Dim template As New CalendarTemplate()
template.RowHeaderColumnCount = 1
template.ColumnCount = 1
template.ColumnHeaderRowCount = 1
template.RowCount = 2
template.RowHeader.Columns(0).Width = 30
' Button型セルを作成します。
Dim buttonCellType As New CalendarButtonCellType()
' テンプレートにButton型セルを配置します。
template.Content.Rows(0).Cells(0).DateFormatType = CalendarDateFormatType.DotNet
template.Content.Rows(0).Cells(0).DateFormat = "d"
template.Content.Rows(1).Cells(0).CellType = buttonCellType.Clone()
template.Content.Rows(1).Cells(0).Value = "ボタン"
GcCalendarGrid1.Template = template
Dim today = DateTime.Today
' TextBox型セルを作成します。
Dim textBoxCellType = New CalendarTextBoxCellType()
' 本日の日付にTextBox型セルを設定します。
GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellType = textBoxCellType
GcCalendarGrid1.Content(today).Rows(1).Cells(0).Value = "テキスト"
[C#]
using GrapeCity.Win.CalendarGrid;
// テンプレートを設定します。
CalendarTemplate template = new CalendarTemplate();
template.RowHeaderColumnCount = 1;
template.ColumnCount = 1;
template.ColumnHeaderRowCount = 1;
template.RowCount = 2;
template.RowHeader.Columns[0].Width = 30;
// Button型セルを作成します。
CalendarButtonCellType buttonCellType = new CalendarButtonCellType();
// テンプレートにButton型セルを配置します。
template.Content.Rows[0].Cells[0].DateFormatType = CalendarDateFormatType.DotNet;
template.Content.Rows[0].Cells[0].DateFormat = "d";
template.Content.Rows[1].Cells[0].CellType = buttonCellType.Clone();
template.Content.Rows[1].Cells[0].Value = "ボタン";
gcCalendarGrid1.Template = template;
var today = DateTime.Today;
// TextBox型セルを作成します。
CalendarTextBoxCellType textBoxCellType = new CalendarTextBoxCellType();
//本日の日付にTextBox型セルを設定します。
gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellType = textBoxCellType;
gcCalendarGrid1.Content[today].Rows[1].Cells[0].Value = "テキスト";