GrapeCity CalendarGrid for Windows Forms 3.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://www.grapecity.co.jp/developer"
   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://www.grapecity.co.jp/developer";
   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);
   }
}
関連トピック

 

 


© 2008 GrapeCity inc. All rights reserved.