GrapeCity.Win.CalendarGrid.v20 アセンブリ > GrapeCity.Win.CalendarGrid 名前空間 : CalendarDynamicCellStyle クラス |
Public Class CalendarDynamicCellStyle Inherits CalendarNamedCellStyle
public class CalendarDynamicCellStyle : CalendarNamedCellStyle
using System; using System.Windows.Forms; using System.Drawing; using GrapeCity.Win.CalendarGrid; namespace CalendarGridSampleCode { public class DynamicCellStyleDemo : Form { private GcCalendarGrid gcCalenderGrid = new GcCalendarGrid(); public DynamicCellStyleDemo() { this.gcCalenderGrid.Dock = DockStyle.Fill; this.Controls.Add(this.gcCalenderGrid); this.Load += Form1_Load; this.Text = "DynamicCellStyle Demo (Background of Date 2014/2/14 will be pink)"; this.Size = new Size(700, 400); } private void Form1_Load(object sender, EventArgs e) { this.gcCalenderGrid.Styles.Clear(); CalendarDynamicCellStyle dynamicCellStyle1 = new CalendarDynamicCellStyle(); dynamicCellStyle1.Name = "dynamicCellStyle"; dynamicCellStyle1.Condition = new DynamicCellStyleCondition(GetNewRowDefaultCellStyle); this.gcCalenderGrid.Styles.Add(dynamicCellStyle1); this.gcCalenderGrid.Template.Content.GetCell(0, 0).CellStyleName = "dynamicCellStyle"; } public CalendarCellStyle GetNewRowDefaultCellStyle(CellStyleContext context) { CalendarCellStyle newCellStyle = new CalendarCellStyle(); if (context.CellPosition.Date == new DateTime(2014, 2, 14)) { newCellStyle.BackColor = Color.Pink; } return newCellStyle; } [STAThreadAttribute()] public static void Main() { Application.EnableVisualStyles(); Application.Run(new DynamicCellStyleDemo()); } } }
Imports System.Windows.Forms Imports System.Drawing Imports GrapeCity.Win.CalendarGrid Namespace CalendarGridSampleCode Public Class DynamicCellStyleDemo Inherits Form Private gcCalenderGrid As New GcCalendarGrid() Public Sub New() Me.gcCalenderGrid.Dock = DockStyle.Fill Me.Controls.Add(Me.gcCalenderGrid) AddHandler Me.Load, AddressOf Form1_Load Me.Text = "DynamicCellStyle Demo (Background of Date 2014/2/14 will be pink)" Me.Size = New Size(700, 400) End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Me.gcCalenderGrid.Styles.Clear() Dim dynamicCellStyle1 As New CalendarDynamicCellStyle() dynamicCellStyle1.Name = "dynamicCellStyle" dynamicCellStyle1.Condition = New DynamicCellStyleCondition(AddressOf GetNewRowDefaultCellStyle) Me.gcCalenderGrid.Styles.Add(dynamicCellStyle1) Me.gcCalenderGrid.Template.Content.GetCell(0, 0).CellStyleName = "dynamicCellStyle" End Sub Public Function GetNewRowDefaultCellStyle(context As CellStyleContext) As CalendarCellStyle Dim newCellStyle As New CalendarCellStyle() If context.CellPosition.[Date] = New DateTime(2014, 2, 14) Then newCellStyle.BackColor = Color.Pink End If Return newCellStyle End Function <STAThreadAttribute> _ Public Shared Sub Main() Application.EnableVisualStyles() Application.Run(New DynamicCellStyleDemo()) End Sub End Class End Namespace
System.Object
GrapeCity.Win.CalendarGrid.CalendarCellStyle
GrapeCity.Win.CalendarGrid.CalendarNamedCellStyle
GrapeCity.Win.CalendarGrid.CalendarDynamicCellStyle