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

LinkLabel型セルのユーザーによるクリックを処理するには、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 linkLabelCellType As New CalendarLinkLabelCellType()
   linkLabelCellType.Text = "https://developer.mescius.jp/"
   GcCalendarGrid1.Content(today).Rows(1).Cells(0).CellType = linkLabelCellType.Clone()
   GcCalendarGrid1.Content(today).Rows(1).Cells(0).Value = False
   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
      Dim linkText As String = DirectCast(gcCalendarGrid.Content(targetCellPosition.Date).Rows(targetCellPosition.RowIndex). _
         Cells(targetCellPosition.ColumnIndex).CellType, CalendarLinkLabelCellType).Text

      Process.Start(linkText)
   End If
End Sub
using GrapeCity.Win.CalendarGrid;

private void Form1_Load(object sender, EventArgs e)
{
   var today = DateTime.Today;
   var linkLabelCellType = new CalendarLinkLabelCellType();
   linkLabelCellType.Text = "https://developer.mescius.jp/";
   gcCalendarGrid1.Content[today].Rows[1].Cells[0].CellType = linkLabelCellType.Clone();
   gcCalendarGrid1.Content[today].Rows[1].Cells[0].Value = false;
   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)
   {
      string linkText = (gcCalendarGrid.Content[targetCellPosition.Date].Rows[targetCellPosition.RowIndex].
         Cells[targetCellPosition.ColumnIndex].CellType as CalendarLinkLabelCellType).Text;

      System.Diagnostics.Process.Start(linkText);
   }
}
関連トピック

 

 


© MESCIUS inc. All rights reserved.