GrapeCity CalendarGrid for Windows Forms 2.0J > CalendarGridの使い方 > セル型 > RadioGroup型セル(CalendarRadioGroupCellType) > 値の変更を検出する |
GcCalendarGrid.CellEditingValueChangedイベントを使用すると、RadioGroup型セルで選択されている値の変更を簡単に検出できます。
Imports GrapeCity.Win.CalendarGrid Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim today As DateTime = DateTime.Today Dim radioGroupCellType = New CalendarRadioGroupCellType() radioGroupCellType.Items.Add("項目A") radioGroupCellType.Items.Add("項目B") radioGroupCellType.ColumnCount = 2 radioGroupCellType.FlowDirection = Orientation.Horizontal GcCalendarGrid1.Content(today).Rows(1).Cells(0).Value = True GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellType = radioGroupCellType.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 radioGroupCellType = new CalendarRadioGroupCellType(); radioGroupCellType.Items.Add("項目"); radioGroupCellType.Items.Add("項目B"); radioGroupCellType.ColumnCount = 2; radioGroupCellType.FlowDirection = Orientation.Horizontal; gcCalendarGrid1.Content[today].Rows[1].Cells[0].Value = true; gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellType = radioGroupCellType.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); } }