GrapeCity CalendarGrid for Windows Forms 2.0J
チェックの値を検出する

GcCalendarGrid.CellEditingValueChangedイベントを使用すると、CheckBox型セルで選択されている値の変更を簡単に検出できます。

Imports GrapeCity.Win.CalendarGrid

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim today As DateTime = DateTime.Today
    Dim checkBoxCellType As New CalendarCheckBoxCellType()
    checkBoxCellType.Text = "アイテム"
    GcCalendarGrid1.Content(today).Rows(1).Cells(0).Value = True
    GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellType = checkBoxCellType.Clone()
    GcCalendarGrid1.ScrollIntoView(today)

    AddHandler GcCalendarGrid1.CellEditingValueChanged, AddressOf GcCalendarGrid1_CellEditingValueChanged
End Sub

Private Sub GcCalendarGrid1_CellEditingValueChanged(sender As Object, e As CalendarCellEditingValueChangedEventArgs)
    Dim today As DateTime = DateTime.Today
    Dim gcCalendarGrid As GcCalendarGrid = DirectCast(sender, GcCalendarGrid)
    Dim targetCellPosition As New CalendarCellPosition(today, 1, 0)

    If e.CellPosition = targetCellPosition Then
        Dim currentCell As CalendarCell = gcCalendarGrid.Content(e.CellPosition.Date).Rows(e.CellPosition.RowIndex).Cells(e.CellPosition.ColumnIndex)
        Console.WriteLine("編集中のセルの値:{0}", e.Value)
        Console.WriteLine("セルの値:{0}", currentCell.Value)
    End If
End Sub
using GrapeCity.Win.CalendarGrid;

private void Form1_Load(object sender, EventArgs e)
{
    var today = DateTime.Today;
    var checkBoxCellType = new CalendarCheckBoxCellType(); checkBoxCellType.Text = "アイテム";
    gcCalendarGrid1.Content[today].Rows[1].Cells[0].Value = true;
    gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellType = checkBoxCellType.Clone();
    gcCalendarGrid1.ScrollIntoView(today);

    gcCalendarGrid1.CellEditingValueChanged += gcCalendarGrid1_CellEditingValueChanged;
}

private void gcCalendarGrid1_CellEditingValueChanged(object sender, CalendarCellEditingValueChangedEventArgs e)
{
    var today = DateTime.Today;
    var gcCalendarGrid = sender as GcCalendarGrid;
    var targetCellPosition = new CalendarCellPosition(today, 1, 0);
    if (e.CellPosition == targetCellPosition)
    {
        CalendarCell currentCell = gcCalendarGrid.Content[e.CellPosition.Date].Rows[e.CellPosition.RowIndex].Cells[e.CellPosition.ColumnIndex];
        Console.WriteLine("編集中のセルの値:{0}", e.Value);
        Console.WriteLine("セルの値:{0}", currentCell.Value);
    }
}
参照

 

 


© 2008 GrapeCity inc. All rights reserved.