作成日: 2017/07/26 最終更新日: 2017/07/26
文書種別
使用方法
詳細
カレンダータイトルを表示するCalendarTitleCaptionクラスのTextプロパティには、書式指定文字列を表示するために"{0}"が設定されているので、カレンダーのビューが表示されたときにCalendarGridのFirstDateInViewプロパティから取得した日付がタイトルヘッダのキャプションに表示されます。
CalendarGridでは、選択した日付にあわせてタイトルヘッダのキャプションを動的に変更する機能は提供していませんが、次のようにCalendarTitleCaptionのTextプロパティにCurrentDateの情報を明示的に設定することで実現することができます。
[Visual Basic]
Imports GrapeCity.Win.CalendarGrid
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
TryCast(Me.GcCalendarGrid1.TitleHeader.Children(0), CalendarTitleCaption).Text = Me.GcCalendarGrid1.DateFormatInfo.FormatDate(Me.GcCalendarGrid1.CurrentDate, "yyyy年M月d日 (ggge年)", CalendarDateFormatType.InputMan)
End Sub
Private Sub GcCalendarGrid1_CurrentCellPositionChanged(sender As Object, e As GrapeCity.Win.CalendarGrid.CalendarCellMoveEventArgs) Handles GcCalendarGrid1.CurrentCellPositionChanged
TryCast(Me.GcCalendarGrid1.TitleHeader.Children(0), CalendarTitleCaption).Text = Me.GcCalendarGrid1.DateFormatInfo.FormatDate(Me.GcCalendarGrid1.CurrentDate, "yyyy年M月d日 (ggge年)", CalendarDateFormatType.InputMan)
End Sub
End Class
[C#]
using GrapeCity.Win.CalendarGrid;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
if (this.gcCalendarGrid1.CurrentDate.HasValue)
{
(this.gcCalendarGrid1.TitleHeader.Children[0] as CalendarTitleCaption).Text = this.gcCalendarGrid1.DateFormatInfo.FormatDate(this.gcCalendarGrid1.CurrentDate.Value, "yyyy年M月d日 (ggge年)", CalendarDateFormatType.InputMan);
}
}
private void gcCalendarGrid1_CurrentCellPositionChanged(object sender, CalendarCellMoveEventArgs e)
{
if (this.gcCalendarGrid1.CurrentDate.HasValue)
{
(this.gcCalendarGrid1.TitleHeader.Children[0] as CalendarTitleCaption).Text = this.gcCalendarGrid1.DateFormatInfo.FormatDate(this.gcCalendarGrid1.CurrentDate.Value, "yyyy年M月d日 (ggge年)", CalendarDateFormatType.InputMan);
}
}
}
}
CalendarGridでは、選択した日付にあわせてタイトルヘッダのキャプションを動的に変更する機能は提供していませんが、次のようにCalendarTitleCaptionのTextプロパティにCurrentDateの情報を明示的に設定することで実現することができます。
[Visual Basic]
Imports GrapeCity.Win.CalendarGrid
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
TryCast(Me.GcCalendarGrid1.TitleHeader.Children(0), CalendarTitleCaption).Text = Me.GcCalendarGrid1.DateFormatInfo.FormatDate(Me.GcCalendarGrid1.CurrentDate, "yyyy年M月d日 (ggge年)", CalendarDateFormatType.InputMan)
End Sub
Private Sub GcCalendarGrid1_CurrentCellPositionChanged(sender As Object, e As GrapeCity.Win.CalendarGrid.CalendarCellMoveEventArgs) Handles GcCalendarGrid1.CurrentCellPositionChanged
TryCast(Me.GcCalendarGrid1.TitleHeader.Children(0), CalendarTitleCaption).Text = Me.GcCalendarGrid1.DateFormatInfo.FormatDate(Me.GcCalendarGrid1.CurrentDate, "yyyy年M月d日 (ggge年)", CalendarDateFormatType.InputMan)
End Sub
End Class
[C#]
using GrapeCity.Win.CalendarGrid;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
if (this.gcCalendarGrid1.CurrentDate.HasValue)
{
(this.gcCalendarGrid1.TitleHeader.Children[0] as CalendarTitleCaption).Text = this.gcCalendarGrid1.DateFormatInfo.FormatDate(this.gcCalendarGrid1.CurrentDate.Value, "yyyy年M月d日 (ggge年)", CalendarDateFormatType.InputMan);
}
}
private void gcCalendarGrid1_CurrentCellPositionChanged(object sender, CalendarCellMoveEventArgs e)
{
if (this.gcCalendarGrid1.CurrentDate.HasValue)
{
(this.gcCalendarGrid1.TitleHeader.Children[0] as CalendarTitleCaption).Text = this.gcCalendarGrid1.DateFormatInfo.FormatDate(this.gcCalendarGrid1.CurrentDate.Value, "yyyy年M月d日 (ggge年)", CalendarDateFormatType.InputMan);
}
}
}
}
旧文書番号
40739