PowerTools CalendarGrid for Windows Forms 1.0J
CalendarDynamicCellStyle クラス
メンバ  使用例 

CellStyleContext クラスに基づく CalendarCellStyle のカスタマイズに使用される特別な CalendarCellStyle を表します。
構文
Public Class CalendarDynamicCellStyle 
   Inherits CalendarNamedCellStyle
public class CalendarDynamicCellStyle : CalendarNamedCellStyle 
解説
この CalendarDynamicCellStyle を使用して、CalendarCellStyle を動的にカスタマイズできます。Condition イベント処理メソッドを関連付けて、特定の CellStyleContext に一致する CalendarCellStyle を返すことができます。
使用例
次のサンプルコードは、CalendarDynamicCellStyle の実装方法を示します。CalendarCellCalendarDynamicCellStyle を設定し、日付が 2014/2/14 の場合に特定のセルスタイルを返しています。
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

参照

CalendarDynamicCellStyle メンバ
GrapeCity.Win.CalendarGrid 名前空間

 

 


© 2014 GrapeCity inc. All rights reserved.