PowerTools CalendarGrid for Windows Forms 1.0J
ResizeMode プロパティ
使用例 

GcCalendarGrid のリサイズモードを取得または設定します。
構文
Public Property ResizeMode As CalendarResizeMode
public CalendarResizeMode ResizeMode {get; set;}

プロパティ値

CalendarResizeMode 値の 1 つ。既定値は CalendarResizeMode.Both です。
使用例
次のサンプルコードは、列の平均リサイズ機能の実装方法を示します。列をリサイズして違いを確かめてください。
using System;
using System.Windows.Forms;
using System.Drawing;
using GrapeCity.Win.CalendarGrid;

namespace CalendarGridSampleCode
{
    class ResizeDemo : Form
    {
        GcCalendarGrid gcCalendarGrid = new GcCalendarGrid();

        public ResizeDemo()
        {
            this.Size = new System.Drawing.Size(900, 400);
            gcCalendarGrid.Template = this.CreateTemplate();
            gcCalendarGrid.Dock = DockStyle.Fill;
            gcCalendarGrid.ResizeMode = CalendarResizeMode.Horizontal;

            gcCalendarGrid.ResizeCompleting += gcCalendarGrid1_ResizeCompleting;
            gcCalendarGrid.ResizeCompleted += gcCalendarGrid1_ResizeCompleted;

            this.Text = "Resizing Demo";
            this.Controls.Add(gcCalendarGrid);
        }

        void gcCalendarGrid1_ResizeCompleted(object sender, GrapeCity.Win.CalendarGrid.CalendarResizeCompletedEventArgs e)
        {
            this.Text = "Resize Completed: { Direction: " + e.Direction + "; ColumnIndex: " + e.LayoutIndex + " }";
        }

        void gcCalendarGrid1_ResizeCompleting(object sender, GrapeCity.Win.CalendarGrid.CalendarResizeCompletingEventArgs e)
        {
            if (e.Direction == Orientation.Horizontal)
            {
                if (((e.LayoutIndex + 1) % 2) == 0)
                {
                    e.Handled = true;

                    int prevWidth = this.gcCalendarGrid.LayoutSettings.HorizontalLayoutInfo[e.LayoutIndex - 1].Length;
                    int currWidth = this.gcCalendarGrid.LayoutSettings.HorizontalLayoutInfo[e.LayoutIndex].Length;

                    int halfOffset = e.ResizeOffset / 2;

                    this.gcCalendarGrid.LayoutSettings.SetHorizontalLength(e.LayoutIndex - 1, prevWidth + halfOffset);
                    this.gcCalendarGrid.LayoutSettings.SetHorizontalLength(e.LayoutIndex, prevWidth + halfOffset);
                }
            }
        }

        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.CalendarHeaderCellType calendarHeaderCellType2 = new GrapeCity.Win.CalendarGrid.CalendarHeaderCellType();
            GrapeCity.Win.CalendarGrid.CalendarHeaderCellType calendarHeaderCellType3 = new GrapeCity.Win.CalendarGrid.CalendarHeaderCellType();
            GrapeCity.Win.CalendarGrid.CalendarHeaderCellType calendarHeaderCellType4 = new GrapeCity.Win.CalendarGrid.CalendarHeaderCellType();

            calendarTemplate1.ColumnCount = 2;
            calendarTemplate1.ColumnHeaderRowCount = 2;

            //The first column is not allowed to resizing.
            calendarTemplate1.ColumnHeader.Columns[0].AllowResize = false;

            calendarTemplate1.RowCount = 2;
            calendarTemplate1.RowHeaderColumnCount = 0;
            calendarTemplate1.ColumnHeader.CellStyleName = "defaultStyle";
            calendarTemplate1.ColumnHeader.GetCell(0, 0).CellType = calendarHeaderCellType1;
            calendarTemplate1.ColumnHeader.GetCell(0, 0).DateFormat = "Resize Me";
            calendarTemplate1.ColumnHeader.GetCell(0, 0).RowSpan = 1;
            calendarTemplate1.ColumnHeader.GetCell(0, 0).ColumnSpan = 2;
            calendarTemplate1.ColumnHeader.GetCell(0, 0).CellStyle.Alignment = GrapeCity.Win.CalendarGrid.CalendarGridContentAlignment.MiddleCenter;
            calendarTemplate1.ColumnHeader.GetCell(0, 1).CellType = calendarHeaderCellType2;
            calendarTemplate1.ColumnHeader.GetCell(1, 0).CellType = calendarHeaderCellType3;
            calendarTemplate1.ColumnHeader.GetCell(1, 0).Value = "AM";
            calendarTemplate1.ColumnHeader.GetCell(1, 0).CellStyle.Alignment = GrapeCity.Win.CalendarGrid.CalendarGridContentAlignment.MiddleCenter;
            calendarTemplate1.ColumnHeader.GetCell(1, 1).CellType = calendarHeaderCellType4;
            calendarTemplate1.ColumnHeader.GetCell(1, 1).Value = "PM";
            calendarTemplate1.ColumnHeader.GetCell(1, 1).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;
            calendarTemplate1.Content.GetCell(0, 0).RowSpan = 1;
            calendarTemplate1.Content.GetCell(0, 0).ColumnSpan = 2;
            return calendarTemplate1;
        }

        private CalendarListView CreateView()
        {
            GrapeCity.Win.CalendarGrid.CalendarListView calendarListView1 = new GrapeCity.Win.CalendarGrid.CalendarListView();
            calendarListView1.DayCount = 7;
            return calendarListView1;
        }

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

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

        Public Sub New()
            Me.Size = New System.Drawing.Size(900, 400)
            gcCalendarGrid.Template = Me.CreateTemplate()
            gcCalendarGrid.Dock = DockStyle.Fill
            gcCalendarGrid.ResizeMode = CalendarResizeMode.Horizontal

            AddHandler gcCalendarGrid.ResizeCompleting, AddressOf gcCalendarGrid1_ResizeCompleting
            AddHandler gcCalendarGrid.ResizeCompleted, AddressOf gcCalendarGrid1_ResizeCompleted

            Me.Text = "Resizing Demo"
            Me.Controls.Add(gcCalendarGrid)
        End Sub

        Private Sub gcCalendarGrid1_ResizeCompleted(sender As Object, e As GrapeCity.Win.CalendarGrid.CalendarResizeCompletedEventArgs)
            Me.Text = "Resize Completed: { Direction: " + e.Direction + "; ColumnIndex: " + e.LayoutIndex + " }"
        End Sub

        Private Sub gcCalendarGrid1_ResizeCompleting(sender As Object, e As GrapeCity.Win.CalendarGrid.CalendarResizeCompletingEventArgs)
            If e.Direction = Orientation.Horizontal Then
                If ((e.LayoutIndex + 1) Mod 2) = 0 Then
                    e.Handled = True

                    Dim prevWidth As Integer = Me.gcCalendarGrid.LayoutSettings.HorizontalLayoutInfo(e.LayoutIndex - 1).Length
                    Dim currWidth As Integer = Me.gcCalendarGrid.LayoutSettings.HorizontalLayoutInfo(e.LayoutIndex).Length

                    Dim halfOffset As Integer = e.ResizeOffset / 2

                    Me.gcCalendarGrid.LayoutSettings.SetHorizontalLength(e.LayoutIndex - 1, prevWidth + halfOffset)
                    Me.gcCalendarGrid.LayoutSettings.SetHorizontalLength(e.LayoutIndex, prevWidth + halfOffset)
                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 calendarHeaderCellType2 As New GrapeCity.Win.CalendarGrid.CalendarHeaderCellType()
            Dim calendarHeaderCellType3 As New GrapeCity.Win.CalendarGrid.CalendarHeaderCellType()
            Dim calendarHeaderCellType4 As New GrapeCity.Win.CalendarGrid.CalendarHeaderCellType()

            calendarTemplate1.ColumnCount = 2
            calendarTemplate1.ColumnHeaderRowCount = 2

            'The first column is not allowed to resizing.
            calendarTemplate1.ColumnHeader.Columns(0).AllowResize = False

            calendarTemplate1.RowCount = 2
            calendarTemplate1.RowHeaderColumnCount = 0
            calendarTemplate1.ColumnHeader.CellStyleName = "defaultStyle"
            calendarTemplate1.ColumnHeader.GetCell(0, 0).CellType = calendarHeaderCellType1
            calendarTemplate1.ColumnHeader.GetCell(0, 0).DateFormat = "Resize Me"
            calendarTemplate1.ColumnHeader.GetCell(0, 0).RowSpan = 1
            calendarTemplate1.ColumnHeader.GetCell(0, 0).ColumnSpan = 2
            calendarTemplate1.ColumnHeader.GetCell(0, 0).CellStyle.Alignment = GrapeCity.Win.CalendarGrid.CalendarGridContentAlignment.MiddleCenter
            calendarTemplate1.ColumnHeader.GetCell(0, 1).CellType = calendarHeaderCellType2
            calendarTemplate1.ColumnHeader.GetCell(1, 0).CellType = calendarHeaderCellType3
            calendarTemplate1.ColumnHeader.GetCell(1, 0).Value = "AM"
            calendarTemplate1.ColumnHeader.GetCell(1, 0).CellStyle.Alignment = GrapeCity.Win.CalendarGrid.CalendarGridContentAlignment.MiddleCenter
            calendarTemplate1.ColumnHeader.GetCell(1, 1).CellType = calendarHeaderCellType4
            calendarTemplate1.ColumnHeader.GetCell(1, 1).Value = "PM"
            calendarTemplate1.ColumnHeader.GetCell(1, 1).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
            calendarTemplate1.Content.GetCell(0, 0).RowSpan = 1
            calendarTemplate1.Content.GetCell(0, 0).ColumnSpan = 2
            Return calendarTemplate1
        End Function

        Private Function CreateView() As CalendarListView
            Dim calendarListView1 As New GrapeCity.Win.CalendarGrid.CalendarListView()
            calendarListView1.DayCount = 7
            Return calendarListView1
        End Function

        <STAThreadAttribute> _
        Public Shared Sub Main()
            Application.EnableVisualStyles()
            Application.Run(New ResizeDemo())
        End Sub
    End Class
End Namespace
参照

GcCalendarGrid クラス
GcCalendarGrid メンバ

 

 


© 2014 GrapeCity inc. All rights reserved.