PowerTools CalendarGrid for Windows Forms 1.0J
ユーザーによるクリックを処理する

Image型セルのユーザーによるクリックを処理するには、GcCalendarGrid.CellContentClickイベントを使用します。

Imports GrapeCity.Win.CalendarGrid

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim today As DateTime = DateTime.Today
    Dim imageCellType As New CalendarImageCellType

    GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellType = imageCellType.Clone()
    GcCalendarGrid1.Content(today).Rows(1).Cells(0).Value = New Bitmap("C:\test.png")
    GcCalendarGrid1.ScrollIntoView(today)

    AddHandler GcCalendarGrid1.CellContentClick, AddressOf GcCalendarGrid1_CellContentClick
End Sub

Private Sub GcCalendarGrid1_CellContentClick(sender As Object, e As GrapeCity.Win.CalendarGrid.CalendarCellEventArgs)
    Dim today As DateTime = DateTime.Today
    Dim targetCellPosition As New CalendarCellPosition(today, 1, 0)
    Dim gcCalendarGrid As GcCalendarGrid = DirectCast(sender, GcCalendarGrid)
    If gcCalendarGrid.CurrentCellPosition = targetCellPosition Then
        MessageBox.Show("クリックされました。")
    End If
End Sub
using GrapeCity.Win.CalendarGrid;

private void Form1_Load(object sender, EventArgs e)
{
    var today = DateTime.Today;
    var imageCellType = new CalendarImageCellType();
    gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellType = imageCellType.Clone();
    gcCalendarGrid1.Content[today].Rows[1].Cells[0].Value = new Bitmap(@"C:\test.png");
    gcCalendarGrid1.CellContentClick += gcCalendarGrid1_CellContentClick;
    gcCalendarGrid1.ScrollIntoView(today);

    gcCalendarGrid1.CellContentClick += gcCalendarGrid1_CellContentClick;
}

private void gcCalendarGrid1_CellContentClick(object sender, CalendarCellEventArgs e)
{
    var today = DateTime.Today;
    var targetCellPosition = new CalendarCellPosition(today, 1, 0);
    var gcCalendarGrid = sender as GcCalendarGrid;
    if (gcCalendarGrid.CurrentCellPosition == targetCellPosition)
    {
        MessageBox.Show("クリックされました。");
    }
}
参照

 

 


© 2014 GrapeCity inc. All rights reserved.