Imports GrapeCity.Win.CalendarGrid
Imports InputManCell = GrapeCity.Win.CalendarGrid.InputMan
Imports CalendarGridInputMan = GrapeCity.Win.CalendarGrid.Editors
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim today As DateTime = DateTime.Today
Dim GcDateTimeCellType As New InputManCell.CalendarGcDateTimeCellType()
' 最大日付と最小日付を設定します。
GcDateTimeCellType.MaxDate = DateTime.Parse("2100/12/31 23:59:59")
GcDateTimeCellType.MinDate = DateTime.Parse("2000/1/1 0:00:00")
' 範囲外の場合に値をどのように制御するかを設定します。
GcDateTimeCellType.MaxMinBehavior = InputMan.MaxMinBehavior.CancelInput
GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellType = GcDateTimeCellType
GcCalendarGrid1.ScrollIntoView(today)
AddHandler GcCalendarGrid1.EditingControlShowing, AddressOf GcCalendarGrid1_EditingControlShowing
End Sub
Private Sub GcCalendarGrid1_EditingControlShowing(sender As Object, e As CalendarEditingControlShowingEventArgs)
If TypeOf e.Control Is CalendarGridInputMan.GcDateTime Then
Dim editor As CalendarGridInputMan.GcDateTime = DirectCast(e.Control, CalendarGridInputMan.GcDateTime)
RemoveHandler editor.InvalidInput, AddressOf editor_InvalidInput
AddHandler editor.InvalidInput, AddressOf editor_InvalidInput
End If
End Sub
Private Sub editor_InvalidInput(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim InvalidInputEventArgs As CalendarGridInputMan.InvalidInputEventArgs = TryCast(e, CalendarGridInputMan.InvalidInputEventArgs)
If InvalidInputEventArgs Is Nothing Then
Exit Sub
End If
' 値が範囲外の場合には、メッセージを表示します。
If InvalidInputEventArgs.ValueOutOfRange Then
MessageBox.Show("範囲外の値です。")
End If
End Sub
using GrapeCity.Win.CalendarGrid;
using InputManCell = GrapeCity.Win.CalendarGrid.InputMan;
using CalendarGridInputMan = GrapeCity.Win.CalendarGrid.Editors;
private void Form1_Load(object sender, EventArgs e)
{
var today = DateTime.Today;
var gcDateTimeCellType = new InputManCell.CalendarGcDateTimeCellType();
// 最大日付と最小日付を設定します。
gcDateTimeCellType.MaxDate = DateTime.Parse("2100/12/31 23:59:59");
gcDateTimeCellType.MinDate = DateTime.Parse("2000/1/1 0:00:00");
// 範囲外の場合に値をどのように制御するかを設定します。
gcDateTimeCellType.MaxMinBehavior = InputManCell.MaxMinBehavior.CancelInput;
gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellType = gcDateTimeCellType;
gcCalendarGrid1.ScrollIntoView(today);
gcCalendarGrid1.EditingControlShowing += gcCalendarGrid1_EditingControlShowing;
}
private void gcCalendarGrid1_EditingControlShowing(object sender, CalendarEditingControlShowingEventArgs e)
{
if (e.Control is CalendarGridInputMan.GcDateTime)
{
CalendarGridInputMan.GcDateTime editor = (CalendarGridInputMan.GcDateTime)e.Control;
editor.InvalidInput -= editor_InvalidInput;
editor.InvalidInput += editor_InvalidInput;
}
}
private void editor_InvalidInput(object sender, EventArgs e)
{
CalendarGridInputMan.InvalidInputEventArgs invalidInputEventArgs = e as CalendarGridInputMan.InvalidInputEventArgs;
if (invalidInputEventArgs == null)
{
return;
}
// 値が範囲外の場合には、メッセージを表示します。
if (invalidInputEventArgs.ValueOutOfRange)
{
MessageBox.Show("範囲外の値です。");
}
}