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

GcCalendarGrid コントロールに予定の情報を表示する CalendarCellType を表します。
構文
Public Class CalendarAppointmentCellType 
   Inherits CalendarCellType
public class CalendarAppointmentCellType : CalendarCellType 
解説
AppointmentCellType は、日付範囲を予定として作成するために使用します。通常、CalendarTemplate の設計時に CalendarAppointmentCellType を使用して日付範囲にまたがる予定を作成する場合は、CalendarRow に AppointmentCellType のみが存在するようにしてください。その他に、Orientation プロパティを使用して予定がまたがる方向を水平または垂直に設定することもできます。通常、Orientation は、GcCalendarGrid.CalendarView の設定によって設定します。ResizeHandlerVisibility は、ResizeHandler を表示するかどうかを設定します。これは GcCalendarGrid の実行時に予定範囲をドラッグするのに役立ちます。また、異なる CalendarShapeRenderer を選択してシェイプの外観を変更したり、CalendarShapeRenderer を継承してシェイプの外観を独自にカスタマイズすることもできます。GcCalendarGrid の実行時にリサイズハンドラをドラッグするときは、その予定の日付が、CalendarCell.Value を持つ他のセルまたは別の Appointment 型セルと重ならないようにしてください。つまり、ドラッグしている Appointment 型セルが有意味のセルを横切ることはできません。
使用例
次のサンプルコードは、GcCalendarGrid コントロールでの予定機能の使用方法を示します。
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GrapeCity.Win.CalendarGrid;

namespace CalendarGridSampleCode
{
    public class AppointmentCellDemo : Form
    {
        private GcCalendarGrid gcCalendarGrid = new GcCalendarGrid();

        public AppointmentCellDemo()
        {
            this.Text = "AppointmentCell Demo";
            this.Size = new Size(800, 700);
            this.StartPosition = FormStartPosition.CenterScreen;
            this.Load += AppointmentCellDemo_Load;

            this.gcCalendarGrid.Template = this.CreateTemplate();
            this.gcCalendarGrid.FirstDateInView = new DateTime(2014, 1, 1);
            this.gcCalendarGrid.AppointmentCellDragging += gcCalendarGrid_AppointmentCellDragging;
            
            // Add GcCalendarGrid to form
            this.gcCalendarGrid.Dock = DockStyle.Fill;
            this.Controls.Add(this.gcCalendarGrid);
        }

        void AppointmentCellDemo_Load(object sender, EventArgs e)
        {
            this.gcCalendarGrid[new DateTime(2014, 1, 12)][1, 0].Value = "You have an appointment between these days.";
            this.gcCalendarGrid[new DateTime(2014, 1, 12)][1, 0].ColumnSpan = 5;

            AngleBracketShapeRenderer render = new AngleBracketShapeRenderer();
            render.ArrowLength = 15;
            render.FillColor = Color.GreenYellow;
            render.LineColor = Color.Orange;
            render.LineStyle = CalendarShapeLineStyle.Thin;
            render.LineWidth = 2;

            (this.gcCalendarGrid[DateTime.Today][1, 0].CellType as CalendarAppointmentCellType).Renderer = render;
        }

        void gcCalendarGrid_AppointmentCellDragging(object sender, AppointmentCellDraggingEventArgs e)
        {
            //The following code will make the appointment limited between 2014/1/1 and 2014/1/31, and the original appointment date cannot be changed to shorter.
            if (e.StartCellPosition.RowIndex == 1 && e.StartCellPosition.ColumnIndex == 0)
            {
                if (e.DraggingHandle == HandlePosition.Left)
                {
                    if (e.TargetCellPosition.Date >= new DateTime(2014, 1, 1) && e.TargetCellPosition.Date <= e.StartCellPosition.Date)
                    {
                        e.AllowDrop = true;
                    }
                    else
                    {
                        e.AllowDrop = false;
                    }
                }
                else if(e.DraggingHandle == HandlePosition.Right)
                {
                    if (e.TargetCellPosition.Date <= new DateTime(2014, 1, 31) && e.TargetCellPosition.Date >= e.EndCellPosition.Date)
                    {
                        e.AllowDrop = true;
                    }
                    else
                    {
                        e.AllowDrop = false;
                    }
                }
            }
        }

        private CalendarTemplate CreateTemplate()
        {
            GrapeCity.Win.CalendarGrid.CalendarTemplate calendarTemplate1 = new GrapeCity.Win.CalendarGrid.CalendarTemplate();
            GrapeCity.Win.CalendarGrid.CalendarHeaderCellType calendarHeaderCellType1 = new GrapeCity.Win.CalendarGrid.CalendarHeaderCellType();
            GrapeCity.Win.CalendarGrid.CalendarAppointmentCellType calendarAppointmentCellType1 = new GrapeCity.Win.CalendarGrid.CalendarAppointmentCellType();
            calendarTemplate1.RowCount = 3;
            calendarTemplate1.RowHeaderColumnCount = 0;
            calendarTemplate1.ColumnHeader.CellStyleName = "defaultStyle";
            calendarHeaderCellType1.SupportLocalization = true;
            calendarTemplate1.ColumnHeader.GetCell(0, 0).CellType = calendarHeaderCellType1;
            calendarTemplate1.ColumnHeader.GetCell(0, 0).DateFormat = "{DayOfWeek}";
            calendarTemplate1.ColumnHeader.GetCell(0, 0).CellStyle.Alignment = GrapeCity.Win.CalendarGrid.CalendarGridContentAlignment.MiddleCenter;
            calendarTemplate1.Content.CellStyleName = "defaultStyle";
            calendarTemplate1.Content.GetCell(0, 0).DateFormat = "d日";
            calendarTemplate1.Content.GetCell(0, 0).DateFormatType = GrapeCity.Win.CalendarGrid.CalendarDateFormatType.DotNet;
            calendarAppointmentCellType1.SupportLocalization = true;
            calendarTemplate1.Content.GetCell(1, 0).CellType = calendarAppointmentCellType1;
            calendarTemplate1.Content.GetCell(2, 0).DateFormat = "{Rokuyou}";
            calendarTemplate1.Content.GetCell(2, 0).CellStyle.Alignment = GrapeCity.Win.CalendarGrid.CalendarGridContentAlignment.MiddleRight;
            return calendarTemplate1;
        }

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

Namespace CalendarGridSampleCode
    Public Class AppointmentCellDemo
        Inherits Form
        Private gcCalendarGrid As New GcCalendarGrid()

        Public Sub New()
            Me.Text = "AppointmentCell Demo"
            Me.Size = New Size(800, 700)
            Me.StartPosition = FormStartPosition.CenterScreen
            AddHandler Me.Load, AddressOf AppointmentCellDemo_Load

            Me.gcCalendarGrid.Template = Me.CreateTemplate()
            Me.gcCalendarGrid.FirstDateInView = New DateTime(2014, 1, 1)
            AddHandler Me.gcCalendarGrid.AppointmentCellDragging, AddressOf gcCalendarGrid_AppointmentCellDragging

            ' Add GcCalendarGrid to form
            Me.gcCalendarGrid.Dock = DockStyle.Fill
            Me.Controls.Add(Me.gcCalendarGrid)
        End Sub

        Private Sub AppointmentCellDemo_Load(sender As Object, e As EventArgs)
            Me.gcCalendarGrid(New DateTime(2014, 1, 12))(1, 0).Value = "You have an appointment between these days."
            Me.gcCalendarGrid(New DateTime(2014, 1, 12))(1, 0).ColumnSpan = 5

            Dim render As New AngleBracketShapeRenderer()
            render.ArrowLength = 15
            render.FillColor = Color.GreenYellow
            render.LineColor = Color.Orange
            render.LineStyle = CalendarShapeLineStyle.Thin
            render.LineWidth = 2

            TryCast(Me.gcCalendarGrid(DateTime.Today)(1, 0).CellType, CalendarAppointmentCellType).Renderer = render
        End Sub

        Private Sub gcCalendarGrid_AppointmentCellDragging(sender As Object, e As AppointmentCellDraggingEventArgs)
            'The following code will make the appointment limited between 2014/1/1 and 2014/1/31, and the original appointment date cannot be changed to shorter.
            If e.StartCellPosition.RowIndex = 1 AndAlso e.StartCellPosition.ColumnIndex = 0 Then
                If e.DraggingHandle = HandlePosition.Left Then
                    If e.TargetCellPosition.[Date] >= New DateTime(2014, 1, 1) AndAlso e.TargetCellPosition.[Date] <= e.StartCellPosition.[Date] Then
                        e.AllowDrop = True
                    Else
                        e.AllowDrop = False
                    End If
                ElseIf e.DraggingHandle = HandlePosition.Right Then
                    If e.TargetCellPosition.[Date] <= New DateTime(2014, 1, 31) AndAlso e.TargetCellPosition.[Date] >= e.EndCellPosition.[Date] Then
                        e.AllowDrop = True
                    Else
                        e.AllowDrop = False
                    End If
                End If
            End If
        End Sub

        Private Function CreateTemplate() As CalendarTemplate
            Dim calendarTemplate1 As New GrapeCity.Win.CalendarGrid.CalendarTemplate()
            Dim calendarHeaderCellType1 As New GrapeCity.Win.CalendarGrid.CalendarHeaderCellType()
            Dim calendarAppointmentCellType1 As New GrapeCity.Win.CalendarGrid.CalendarAppointmentCellType()
            calendarTemplate1.RowCount = 3
            calendarTemplate1.RowHeaderColumnCount = 0
            calendarTemplate1.ColumnHeader.CellStyleName = "defaultStyle"
            calendarHeaderCellType1.SupportLocalization = True
            calendarTemplate1.ColumnHeader.GetCell(0, 0).CellType = calendarHeaderCellType1
            calendarTemplate1.ColumnHeader.GetCell(0, 0).DateFormat = "{DayOfWeek}"
            calendarTemplate1.ColumnHeader.GetCell(0, 0).CellStyle.Alignment = GrapeCity.Win.CalendarGrid.CalendarGridContentAlignment.MiddleCenter
            calendarTemplate1.Content.CellStyleName = "defaultStyle"
            calendarTemplate1.Content.GetCell(0, 0).DateFormat = "d日"
            calendarTemplate1.Content.GetCell(0, 0).DateFormatType = GrapeCity.Win.CalendarGrid.CalendarDateFormatType.DotNet
            calendarAppointmentCellType1.SupportLocalization = True
            calendarTemplate1.Content.GetCell(1, 0).CellType = calendarAppointmentCellType1
            calendarTemplate1.Content.GetCell(2, 0).DateFormat = "{Rokuyou}"
            calendarTemplate1.Content.GetCell(2, 0).CellStyle.Alignment = GrapeCity.Win.CalendarGrid.CalendarGridContentAlignment.MiddleRight
            Return calendarTemplate1
        End Function

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

System.Object
   GrapeCity.Win.CalendarGrid.CalendarCellType
      GrapeCity.Win.CalendarGrid.CalendarAppointmentCellType

参照

CalendarAppointmentCellType メンバ
GrapeCity.Win.CalendarGrid 名前空間
CalendarShapeRenderer クラス
CalendarView クラス

 

 


c 2008 GrapeCity inc. All rights reserved.