Imports GrapeCity.Win.CalendarGrid
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim today As DateTime = DateTime.Today
Dim textBoxCellType As New CalendarTextBoxCellType()
GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellType = textBoxCellType
GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellStyle.BackColor = Color.Azure
GcCalendarGrid1.ScrollIntoView(today)
End Sub
Private Sub GcCalendarGrid1_CellValidating(sender As Object, e As GrapeCity.Win.CalendarGrid.CalendarCellValidatingEventArgs) Handles GcCalendarGrid1.CellValidating
Dim gcCalendarGrid As GcCalendarGrid = DirectCast(sender, GcCalendarGrid)
If TypeOf gcCalendarGrid.Content(e.CellPosition.Date).Rows(e.CellPosition.RowIndex).Cells(e.CellPosition.ColumnIndex).CellType Is CalendarTextBoxCellType Then
Dim beforeEdit As Object = gcCalendarGrid.Content(e.CellPosition.Date).Rows(e.CellPosition.RowIndex).Cells(e.CellPosition.ColumnIndex).Value
If (beforeEdit IsNot Nothing) Then
Console.WriteLine("編集前の値:{0}", beforeEdit.ToString())
Else
Console.WriteLine("編集前の値:(なし)")
End If
If gcCalendarGrid.EditingControl IsNot Nothing Then
Console.WriteLine("編集中の値:{0}", gcCalendarGrid.EditingControl.Text)
Else
Console.WriteLine("編集中の値:(なし)")
End If
Else
Console.WriteLine("現在のセルはTextBox型ではありません")
End If
End Sub
using GrapeCity.Win.CalendarGrid;
private void Form1_Load(object sender, EventArgs e)
{
var today = DateTime.Today;
var textBoxCellType = new CalendarTextBoxCellType();
gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellType = textBoxCellType;
gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellStyle.BackColor = Color.Azure;
gcCalendarGrid1.ScrollIntoView(today);
gcCalendarGrid1.CellValidating += gcCalendarGrid1_CellValidating;
}
void gcCalendarGrid1_CellValidating(object sender, CalendarCellValidatingEventArgs e)
{
var gcCalendarGrid = sender as GcCalendarGrid;
if (gcCalendarGrid.Content[e.CellPosition.Date].Rows[e.CellPosition.RowIndex].Cells[e.CellPosition.ColumnIndex].CellType is CalendarTextBoxCellType)
{
object beforeEdit = gcCalendarGrid.Content[e.CellPosition.Date].Rows[e.CellPosition.RowIndex].Cells[e.CellPosition.ColumnIndex].Value;
if (beforeEdit != null)
{
Console.WriteLine("編集前の値:{0}", beforeEdit.ToString());
}
else
{
Console.WriteLine("編集前の値:(なし)");
}
if (gcCalendarGrid.EditingControl != null)
{
Console.WriteLine("編集中の値:{0}", gcCalendarGrid.EditingControl.Text);
}
else
{
Console.WriteLine("編集中の値:(なし)");
}
}
else
{
Console.WriteLine("現在のセルはTextBox型ではありません");
}
}