GrapeCity.Win.CalendarGrid.v10 アセンブリ > GrapeCity.Win.CalendarGrid 名前空間 : CalendarLinkLabelCellType クラス |
Public Class CalendarLinkLabelCellType Inherits CalendarLabelCellType
public class CalendarLinkLabelCellType : CalendarLabelCellType
using System; using System.Drawing; using System.Windows.Forms; using System.Data; using System.Diagnostics; using GrapeCity.Win.CalendarGrid; namespace CalendarGridSampleCode { public class LinkLabelCellDemo : Form { private GcCalendarGrid gcCalendarGrid1 = new GcCalendarGrid(); public LinkLabelCellDemo() { this.Text = "LinkLabelCell Demo"; this.Size = new Size(550, 300); // Add GcCalendarGrid to form this.gcCalendarGrid1.Dock = DockStyle.Fill; this.Controls.Add(this.gcCalendarGrid1); this.Load += Form1_Load; } private void Form1_Load(object sender, EventArgs e) { CalendarTextBoxCellType nameTextBox = new CalendarTextBoxCellType(); CalendarTemplate template1 = CalendarTemplate.CreateDefaultTemplate(); template1.Content[1, 0].CellType = nameTextBox; template1.Content[2, 0].Name = "Address"; this.gcCalendarGrid1.Template = template1; this.gcCalendarGrid1.CurrentCellPosition = new CalendarCellPosition(new DateTime(2014, 2, 3), 1, 0); this.gcCalendarGrid1.CellClick += gcCalendarGrid1_CellClick; this.FillValue(); } private CalendarLinkLabelCellType CreateAddressLinkLabelCell() { CalendarLinkLabelCellType linkLabelCell = new CalendarLinkLabelCellType(); // Customize behavior of link label. linkLabelCell.LinkBehavior = LinkBehavior.HoverUnderline; // Customize colors when link label in different status. linkLabelCell.LinkColor = Color.Blue; linkLabelCell.ActiveLinkColor = Color.Red; linkLabelCell.VisitedLinkColor = Color.Purple; return linkLabelCell; } void gcCalendarGrid1_CellClick(object sender, CalendarCellEventArgs e) { if (e.CellPosition.Name == "Address") { CalendarCell cell = gcCalendarGrid1[e.CellPosition.Date][e.CellPosition.RowIndex, e.CellPosition.ColumnIndex]; if (cell.CellType is CalendarLinkLabelCellType) { object link = (cell.CellType as CalendarLinkLabelCellType).Text; if (link != null) { Process.Start(link.ToString()); } } } gcCalendarGrid1.LayoutSettings.PerformHorizontalAutoFit(0); } private void FillValue() { CalendarLinkLabelCellType addressLinkLabelCell1 = new CalendarLinkLabelCellType(); addressLinkLabelCell1.Text = "http://www.grapecity.com/"; CalendarLinkLabelCellType addressLinkLabelCell2 = new CalendarLinkLabelCellType(); addressLinkLabelCell2.Text = "http://www.grapecity.com/japan/"; CalendarLinkLabelCellType addressLinkLabelCell3 = new CalendarLinkLabelCellType(); addressLinkLabelCell3.Text = "http://www.grapecity.com/japan/support/database/dotnet_productlist.htm"; gcCalendarGrid1[new DateTime(2014, 2, 3)][1, 0].Value = "GrapeCity"; gcCalendarGrid1[new DateTime(2014, 2, 3)][2, 0].CellType = addressLinkLabelCell1; gcCalendarGrid1[new DateTime(2014, 2, 10)][1, 0].Value = "GrapeCity japan"; gcCalendarGrid1[new DateTime(2014, 2, 10)][2, 0].CellType = addressLinkLabelCell2; gcCalendarGrid1[new DateTime(2014, 2, 17)][1, 0].Value = "GrapeCity Product Lists"; gcCalendarGrid1[new DateTime(2014, 2, 17)][2, 0].CellType = addressLinkLabelCell3; gcCalendarGrid1.LayoutSettings.PerformHorizontalAutoFit(0); } [STAThreadAttribute()] public static void Main() { Application.EnableVisualStyles(); Application.Run(new LinkLabelCellDemo()); } } }
Imports System.Drawing Imports System.Windows.Forms Imports System.Data Imports System.Diagnostics Imports GrapeCity.Win.CalendarGrid Namespace CalendarGridSampleCode Public Class LinkLabelCellDemo Inherits Form Private gcCalendarGrid1 As New GcCalendarGrid() Public Sub New() Me.Text = "LinkLabelCell Demo" Me.Size = New Size(550, 300) ' Add GcCalendarGrid to form Me.gcCalendarGrid1.Dock = DockStyle.Fill Me.Controls.Add(Me.gcCalendarGrid1) AddHandler Me.Load, AddressOf Form1_Load End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Dim nameTextBox As New CalendarTextBoxCellType() Dim template1 As CalendarTemplate = CalendarTemplate.CreateDefaultTemplate() template1.Content(1, 0).CellType = nameTextBox template1.Content(2, 0).Name = "Address" Me.gcCalendarGrid1.Template = template1 Me.gcCalendarGrid1.CurrentCellPosition = New CalendarCellPosition(New DateTime(2014, 2, 3), 1, 0) AddHandler Me.gcCalendarGrid1.CellClick, AddressOf gcCalendarGrid1_CellClick Me.FillValue() End Sub Private Function CreateAddressLinkLabelCell() As CalendarLinkLabelCellType Dim linkLabelCell As New CalendarLinkLabelCellType() ' Customize behavior of link label. linkLabelCell.LinkBehavior = LinkBehavior.HoverUnderline ' Customize colors when link label in different status. linkLabelCell.LinkColor = Color.Blue linkLabelCell.ActiveLinkColor = Color.Red linkLabelCell.VisitedLinkColor = Color.Purple Return linkLabelCell End Function Private Sub gcCalendarGrid1_CellClick(sender As Object, e As CalendarCellEventArgs) If e.CellPosition.Name = "Address" Then Dim cell As CalendarCell = gcCalendarGrid1(e.CellPosition.[Date])(e.CellPosition.RowIndex, e.CellPosition.ColumnIndex) If TypeOf cell.CellType Is CalendarLinkLabelCellType Then Dim link As Object = TryCast(cell.CellType, CalendarLinkLabelCellType).Text If link IsNot Nothing Then Process.Start(link.ToString()) End If End If End If gcCalendarGrid1.LayoutSettings.PerformHorizontalAutoFit(0) End Sub Private Sub FillValue() Dim addressLinkLabelCell1 As New CalendarLinkLabelCellType() addressLinkLabelCell1.Text = "http://www.grapecity.com/" Dim addressLinkLabelCell2 As New CalendarLinkLabelCellType() addressLinkLabelCell2.Text = "http://www.grapecity.com/japan/" Dim addressLinkLabelCell3 As New CalendarLinkLabelCellType() addressLinkLabelCell3.Text = "http://www.grapecity.com/japan/support/database/dotnet_productlist.htm" gcCalendarGrid1(New DateTime(2014, 2, 3))(1, 0).Value = "GrapeCity" gcCalendarGrid1(New DateTime(2014, 2, 3))(2, 0).CellType = addressLinkLabelCell1 gcCalendarGrid1(New DateTime(2014, 2, 10))(1, 0).Value = "GrapeCity japan" gcCalendarGrid1(New DateTime(2014, 2, 10))(2, 0).CellType = addressLinkLabelCell2 gcCalendarGrid1(New DateTime(2014, 2, 17))(1, 0).Value = "GrapeCity Product Lists" gcCalendarGrid1(New DateTime(2014, 2, 17))(2, 0).CellType = addressLinkLabelCell3 gcCalendarGrid1.LayoutSettings.PerformHorizontalAutoFit(0) End Sub <STAThreadAttribute> _ Public Shared Sub Main() Application.EnableVisualStyles() Application.Run(New LinkLabelCellDemo()) End Sub End Class End Namespace
System.Object
GrapeCity.Win.CalendarGrid.CalendarCellType
GrapeCity.Win.CalendarGrid.CalendarLabelCellType
GrapeCity.Win.CalendarGrid.CalendarLinkLabelCellType