GrapeCity CalendarGrid for Windows Forms 2.0J
CalendarConditionalCellStyle クラス
メンバ  使用例 

指定した条件を使用してスタイルをカスタマイズできる特別な CalendarCellStyle を表します。
構文
Public Class CalendarConditionalCellStyle 
   Inherits CalendarNamedCellStyle
public class CalendarConditionalCellStyle : CalendarNamedCellStyle 
解説
CalendarConditionalCellStyle には CalendarConditionalCellStyleItem のコレクションが含まれます。コレクション内のいずれかの CalendarConditionalCellStyleItem が現在の CalendarCellCellStyleContext に一致した場合、その CellStyle が使用されます。
使用例
次のサンプルコードは、条件付きセルスタイルの実装方法を示します。関連する日付が月曜日の場合、セルの背景色がライムになります。関連する日付が金曜日の場合、セルの背景色が黄色になります。関連する日付が隣接日の場合、セルの背景色が赤になります。
using System;
using System.Windows.Forms;
using System.Drawing;
using GrapeCity.Win.CalendarGrid;

namespace CalendarGridSampleCode
{
    public class ConditionalCellStyleDemo : Form
    {
        private GcCalendarGrid gcCalendarGrid1 = new GcCalendarGrid();
        private Label label1 = new Label();

        public ConditionalCellStyleDemo()
        {
            this.Text = "ConditionalCellStyle Demo";
            this.Size = new Size(600, 400);

            this.gcCalendarGrid1.Dock = DockStyle.Fill;
            this.Controls.Add(this.gcCalendarGrid1);

            label1.Text = "When specified date match condition, the corresponding background will be painted.";
            label1.Height = 50;
            label1.Dock = DockStyle.Bottom;
            label1.BackColor = SystemColors.Info;
            label1.ForeColor = Color.Red;
            this.Controls.Add(label1);

            this.Load += Form1_Load;

            this.StartPosition = FormStartPosition.CenterScreen;
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            CalendarCellStyle cellStyle1 = new CalendarCellStyle();
            cellStyle1.BackColor = Color.Lime;

            CalendarCellStyle cellStyle2 = new CalendarCellStyle();
            cellStyle2.BackColor = Color.Yellow;

            CalendarCellStyle cellStyle3 = new CalendarCellStyle();
            cellStyle3.BackColor = Color.Red;

            CalendarConditionalCellStyleItem item1 = new CalendarConditionalCellStyleItem(cellStyle1, ConditionalStyleOperator.IsMonday);            
            CalendarConditionalCellStyleItem item2 = new CalendarConditionalCellStyleItem(cellStyle2, ConditionalStyleOperator.IsFriday);          
            CalendarConditionalCellStyleItem item3 = new CalendarConditionalCellStyleItem(cellStyle3, ConditionalStyleOperator.IsTrailingDay);
        
            CalendarConditionalCellStyle conditionalStyle1 = new CalendarConditionalCellStyle("defaultCalendarConditionalStyle");
            conditionalStyle1.Items.Add(item1);
            conditionalStyle1.Items.Add(item2);
            conditionalStyle1.Items.Add(item3);
            this.gcCalendarGrid1.Styles.Clear();
            this.gcCalendarGrid1.Template.Content.GetCell(0, 0).CellStyleName = "defaultCalendarConditionalStyle";
            this.gcCalendarGrid1.Styles.Add(conditionalStyle1);
        }

        [STAThreadAttribute()]
        public static void Main()
        {
            Application.EnableVisualStyles();
            Application.Run(new ConditionalCellStyleDemo());
        }
    }
}
Imports System.Windows.Forms
Imports System.Drawing
Imports GrapeCity.Win.CalendarGrid

Namespace CalendarGridSampleCode
    Public Class ConditionalCellStyleDemo
        Inherits Form
        Private gcCalendarGrid1 As New GcCalendarGrid()
        Private label1 As New Label()

        Public Sub New()
            Me.Text = "ConditionalCellStyle Demo"
            Me.Size = New Size(600, 400)

            Me.gcCalendarGrid1.Dock = DockStyle.Fill
            Me.Controls.Add(Me.gcCalendarGrid1)

            label1.Text = "When specified date match condition, the corresponding background will be painted."
            label1.Height = 50
            label1.Dock = DockStyle.Bottom
            label1.BackColor = SystemColors.Info
            label1.ForeColor = Color.Red
            Me.Controls.Add(label1)

            AddHandler Me.Load, AddressOf Form1_Load

            Me.StartPosition = FormStartPosition.CenterScreen
        End Sub
        Private Sub Form1_Load(sender As Object, e As EventArgs)
            Dim cellStyle1 As New CalendarCellStyle()
            cellStyle1.BackColor = Color.Lime

            Dim cellStyle2 As New CalendarCellStyle()
            cellStyle2.BackColor = Color.Yellow

            Dim cellStyle3 As New CalendarCellStyle()
            cellStyle3.BackColor = Color.Red

            Dim item1 As New CalendarConditionalCellStyleItem(cellStyle1, ConditionalStyleOperator.IsMonday)
            Dim item2 As New CalendarConditionalCellStyleItem(cellStyle2, ConditionalStyleOperator.IsFriday)
            Dim item3 As New CalendarConditionalCellStyleItem(cellStyle3, ConditionalStyleOperator.IsTrailingDay)

            Dim conditionalStyle1 As New CalendarConditionalCellStyle("defaultCalendarConditionalStyle")
            conditionalStyle1.Items.Add(item1)
            conditionalStyle1.Items.Add(item2)
            conditionalStyle1.Items.Add(item3)
            Me.gcCalendarGrid1.Styles.Clear()
            Me.gcCalendarGrid1.Template.Content.GetCell(0, 0).CellStyleName = "defaultCalendarConditionalStyle"
            Me.gcCalendarGrid1.Styles.Add(conditionalStyle1)
        End Sub

        <STAThreadAttribute> _
        Public Shared Sub Main()
            Application.EnableVisualStyles()
            Application.Run(New ConditionalCellStyleDemo())
        End Sub
    End Class
End Namespace
継承階層

System.Object
   GrapeCity.Win.CalendarGrid.CalendarCellStyle
      GrapeCity.Win.CalendarGrid.CalendarNamedCellStyle
         GrapeCity.Win.CalendarGrid.CalendarConditionalCellStyle

参照

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

 

 


c 2008 GrapeCity inc. All rights reserved.