GrapeCity.Win.CalendarGrid.v10 アセンブリ > GrapeCity.Win.CalendarGrid 名前空間 : CalendarView クラス |
CalendarView は、GcCalendarGrid の日付のレイアウトを定義するために使用します。各日付は、CalendarTemplate 内の関連する CalendarTable で定義された内部セルのレイアウトと外観を使用して表現されます。
各 CalendarView は、日付のレイアウト、ナビゲーション動作、およびスクロール動作がそれぞれ異なります。通常は、まず適切なビューを選択してから、個々の要件に従ってそのビュー用の CalendarTemplate を設計します。
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 CalendarViewDemo : Form { private GcCalendarGrid gcCalendarGrid1 = new GcCalendarGrid(); private TableLayoutPanel tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); private TableLayoutPanel tableLayoutPanel2 = new TableLayoutPanel(); private Button button1 = new Button(); private Button button2 = new Button(); private Button button3 = new Button(); private Button button4 = new Button(); public CalendarViewDemo() { this.tableLayoutPanel1.ColumnCount = 1; this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; this.tableLayoutPanel1.RowCount = 2; this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 90F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); this.tableLayoutPanel1.Size = new System.Drawing.Size(554, 426); this.gcCalendarGrid1.Dock = DockStyle.Fill; this.tableLayoutPanel1.Controls.Add(this.gcCalendarGrid1, 0, 0); this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel2, 0, 1); this.button1.Dock = System.Windows.Forms.DockStyle.Fill; this.button1.Text = "MonthView"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += button1_Click; this.button2.Dock = System.Windows.Forms.DockStyle.Fill; this.button2.Text = "WeekView"; this.button2.UseVisualStyleBackColor = true; this.button2.Click += button2_Click; this.button3.Dock = System.Windows.Forms.DockStyle.Fill; this.button3.Text = "MultiColumnMonthView"; this.button3.UseVisualStyleBackColor = true; this.button3.Click += button3_Click; this.button4.Dock = System.Windows.Forms.DockStyle.Fill; this.button4.Text = "ListView"; this.button4.UseVisualStyleBackColor = true; this.button4.Click += button4_Click; this.tableLayoutPanel2.ColumnCount = 4; this.tableLayoutPanel2.RowCount = 1; this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25f)); this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25f)); this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25f)); this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25f)); this.tableLayoutPanel2.Controls.Add(this.button1, 0, 0); this.tableLayoutPanel2.Controls.Add(this.button2, 1, 0); this.tableLayoutPanel2.Controls.Add(this.button3, 2, 0); this.tableLayoutPanel2.Controls.Add(this.button4, 3, 0); this.tableLayoutPanel2.Dock = DockStyle.Fill; this.Text = "Calendar View Demo"; this.Size = new Size(800, 700); this.StartPosition = FormStartPosition.CenterScreen; this.Controls.Add(this.tableLayoutPanel1); } private void button1_Click(object sender, EventArgs e) { this.UseMonthView(); } private void button2_Click(object sender, EventArgs e) { this.UseWeekView(); } private void button3_Click(object sender, EventArgs e) { this.UseMonthMultiColumnView(); } private void button4_Click(object sender, EventArgs e) { this.UseListView(); } private void UseMonthView() { CalendarMonthView monthView = new CalendarMonthView(); monthView.Dimensions = new Size(3, 4); monthView.MinScrollCount = 12; this.gcCalendarGrid1.CalendarView = monthView; CalendarTemplate template = new CalendarTemplate(1, 1, 2, 1); template.ColumnHeader.CellStyle.Alignment = CalendarGridContentAlignment.MiddleCenter; template.ColumnHeader[0, 0].DateFormat = CalendarDateFormats.Month; template.ColumnHeader[0, 0].AutoMergeMode = AutoMergeMode.Horizontal; template.ColumnHeader[1, 0].DateFormat = CalendarDateFormats.ShortestDayOfWeek; template.RowHeader.CellStyle.Alignment = CalendarGridContentAlignment.MiddleCenter; template.RowHeader.CellStyle.ForeColor = Color.Green; template.RowHeader.Columns[0].Width = 30; template.RowHeader[0, 0].DateFormat = CalendarDateFormats.WeekNumber; template.RowHeader[0, 0].CellStyle.Alignment = CalendarGridContentAlignment.MiddleCenter; template.Content.Columns[0].Width = 30; template.Content.CellStyleName = this.gcCalendarGrid1.Styles[0].Name; template.Content[0, 0].DateFormat = CalendarDateFormats.Day; this.gcCalendarGrid1.Template = template; this.gcCalendarGrid1.FirstDateInView = new DateTime(DateTime.Today.Year, 1, 1); } private void UseWeekView() { CalendarWeekView weekView = new CalendarWeekView(); weekView.WeekCount = 2; weekView.ShowWeekend = false; this.gcCalendarGrid1.CalendarView = weekView; this.gcCalendarGrid1.Template = CalendarTemplate.CreateDefaultTemplate(); } private void UseMonthMultiColumnView() { CalendarMonthMultiColumnView monthView = new CalendarMonthMultiColumnView(); monthView.MonthCount = 12; monthView.MinScrollCount = 12; monthView.ColumnBreaks = new int[] { 10, 20 }; monthView.Orientation = Orientation.Vertical; this.gcCalendarGrid1.CalendarView = monthView; CalendarTemplate template = new CalendarTemplate(1, 1, 1, 0); template.ColumnHeader[0, 0].DateFormat = CalendarDateFormats.Month; template.ColumnHeader[0, 0].AutoMergeMode = AutoMergeMode.Horizontal; template.ColumnHeader[0, 0].CellStyle.Alignment = CalendarGridContentAlignment.MiddleCenter; template.Content.Columns[0].Width = 30; template.Content[0, 0].DateFormat = CalendarDateFormats.Day; this.gcCalendarGrid1.Template = template; this.gcCalendarGrid1.FirstDateInView = new DateTime(DateTime.Today.Year, 1, 1); } private void UseListView() { CalendarListView listView = new CalendarListView(); listView.DayCount = 100; listView.DateAlignment = DateAlignment.Month; this.gcCalendarGrid1.CalendarView = listView; CalendarTemplate template = new CalendarTemplate(20, 1, 2, 1); template.ColumnHeader.CellStyle.Alignment = CalendarGridContentAlignment.MiddleCenter; template.ColumnHeader[0, 0].DateFormat = CalendarDateFormats.Month; template.ColumnHeader[0, 0].AutoMergeMode = AutoMergeMode.Horizontal; template.ColumnHeader[0, 0].AllowContentFloat = true; template.ColumnHeader[1, 0].DateFormat = CalendarDateFormats.Day; template.RowHeader.Columns[0].Width = 30; template.Content.Columns[0].Width = 30; this.gcCalendarGrid1.Template = template; } [STAThreadAttribute] public static void Main() { Application.EnableVisualStyles(); Application.Run(new CalendarViewDemo()); } } }
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 CalendarViewDemo Inherits Form Private gcCalendarGrid1 As New GcCalendarGrid() Private tableLayoutPanel1 As TableLayoutPanel = New System.Windows.Forms.TableLayoutPanel() Private tableLayoutPanel2 As New TableLayoutPanel() Private button1 As New Button() Private button2 As New Button() Private button3 As New Button() Private button4 As New Button() Public Sub New() Me.tableLayoutPanel1.ColumnCount = 1 Me.tableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100.0F)) Me.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill Me.tableLayoutPanel1.Location = New System.Drawing.Point(0, 0) Me.tableLayoutPanel1.Name = "tableLayoutPanel1" Me.tableLayoutPanel1.RowCount = 2 Me.tableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 90.0F)) Me.tableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10.0F)) Me.tableLayoutPanel1.Size = New System.Drawing.Size(554, 426) Me.gcCalendarGrid1.Dock = DockStyle.Fill Me.tableLayoutPanel1.Controls.Add(Me.gcCalendarGrid1, 0, 0) Me.tableLayoutPanel1.Controls.Add(Me.tableLayoutPanel2, 0, 1) Me.button1.Dock = System.Windows.Forms.DockStyle.Fill Me.button1.Text = "MonthView" Me.button1.UseVisualStyleBackColor = True AddHandler Me.button1.Click, AddressOf button1_Click Me.button2.Dock = System.Windows.Forms.DockStyle.Fill Me.button2.Text = "WeekView" Me.button2.UseVisualStyleBackColor = True AddHandler Me.button2.Click, AddressOf button2_Click Me.button3.Dock = System.Windows.Forms.DockStyle.Fill Me.button3.Text = "MultiColumnMonthView" Me.button3.UseVisualStyleBackColor = True AddHandler Me.button3.Click, AddressOf button3_Click Me.button4.Dock = System.Windows.Forms.DockStyle.Fill Me.button4.Text = "ListView" Me.button4.UseVisualStyleBackColor = True AddHandler Me.button4.Click, AddressOf button4_Click Me.tableLayoutPanel2.ColumnCount = 4 Me.tableLayoutPanel2.RowCount = 1 Me.tableLayoutPanel2.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25.0F)) Me.tableLayoutPanel2.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25.0F)) Me.tableLayoutPanel2.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25.0F)) Me.tableLayoutPanel2.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25.0F)) Me.tableLayoutPanel2.Controls.Add(Me.button1, 0, 0) Me.tableLayoutPanel2.Controls.Add(Me.button2, 1, 0) Me.tableLayoutPanel2.Controls.Add(Me.button3, 2, 0) Me.tableLayoutPanel2.Controls.Add(Me.button4, 3, 0) Me.tableLayoutPanel2.Dock = DockStyle.Fill Me.Text = "Calendar View Demo" Me.Size = New Size(800, 700) Me.StartPosition = FormStartPosition.CenterScreen Me.Controls.Add(Me.tableLayoutPanel1) End Sub Private Sub button1_Click(sender As Object, e As EventArgs) Me.UseMonthView() End Sub Private Sub button2_Click(sender As Object, e As EventArgs) Me.UseWeekView() End Sub Private Sub button3_Click(sender As Object, e As EventArgs) Me.UseMonthMultiColumnView() End Sub Private Sub button4_Click(sender As Object, e As EventArgs) Me.UseListView() End Sub Private Sub UseMonthView() Dim monthView As New CalendarMonthView() monthView.Dimensions = New Size(3, 4) monthView.MinScrollCount = 12 Me.gcCalendarGrid1.CalendarView = monthView Dim template As New CalendarTemplate(1, 1, 2, 1) template.ColumnHeader.CellStyle.Alignment = CalendarGridContentAlignment.MiddleCenter template.ColumnHeader(0, 0).DateFormat = CalendarDateFormats.Month template.ColumnHeader(0, 0).AutoMergeMode = AutoMergeMode.Horizontal template.ColumnHeader(1, 0).DateFormat = CalendarDateFormats.ShortestDayOfWeek template.RowHeader.CellStyle.Alignment = CalendarGridContentAlignment.MiddleCenter template.RowHeader.CellStyle.ForeColor = Color.Green template.RowHeader.Columns(0).Width = 30 template.RowHeader(0, 0).DateFormat = CalendarDateFormats.WeekNumber template.RowHeader(0, 0).CellStyle.Alignment = CalendarGridContentAlignment.MiddleCenter template.Content.Columns(0).Width = 30 template.Content.CellStyleName = Me.gcCalendarGrid1.Styles(0).Name template.Content(0, 0).DateFormat = CalendarDateFormats.Day Me.gcCalendarGrid1.Template = template Me.gcCalendarGrid1.FirstDateInView = New DateTime(DateTime.Today.Year, 1, 1) End Sub Private Sub UseWeekView() Dim weekView As New CalendarWeekView() weekView.WeekCount = 2 weekView.ShowWeekend = False Me.gcCalendarGrid1.CalendarView = weekView Me.gcCalendarGrid1.Template = CalendarTemplate.CreateDefaultTemplate() End Sub Private Sub UseMonthMultiColumnView() Dim monthView As New CalendarMonthMultiColumnView() monthView.MonthCount = 12 monthView.MinScrollCount = 12 monthView.ColumnBreaks = New Integer() {10, 20} monthView.Orientation = Orientation.Vertical Me.gcCalendarGrid1.CalendarView = monthView Dim template As New CalendarTemplate(1, 1, 1, 0) template.ColumnHeader(0, 0).DateFormat = CalendarDateFormats.Month template.ColumnHeader(0, 0).AutoMergeMode = AutoMergeMode.Horizontal template.ColumnHeader(0, 0).CellStyle.Alignment = CalendarGridContentAlignment.MiddleCenter template.Content.Columns(0).Width = 30 template.Content(0, 0).DateFormat = CalendarDateFormats.Day Me.gcCalendarGrid1.Template = template Me.gcCalendarGrid1.FirstDateInView = New DateTime(DateTime.Today.Year, 1, 1) End Sub Private Sub UseListView() Dim listView As New CalendarListView() listView.DayCount = 100 listView.DateAlignment = DateAlignment.Month Me.gcCalendarGrid1.CalendarView = listView Dim template As New CalendarTemplate(20, 1, 2, 1) template.ColumnHeader.CellStyle.Alignment = CalendarGridContentAlignment.MiddleCenter template.ColumnHeader(0, 0).DateFormat = CalendarDateFormats.Month template.ColumnHeader(0, 0).AutoMergeMode = AutoMergeMode.Horizontal template.ColumnHeader(0, 0).AllowContentFloat = True template.ColumnHeader(1, 0).DateFormat = CalendarDateFormats.Day template.RowHeader.Columns(0).Width = 30 template.Content.Columns(0).Width = 30 Me.gcCalendarGrid1.Template = template End Sub <STAThreadAttribute> _ Public Shared Sub Main() Application.EnableVisualStyles() Application.Run(New CalendarViewDemo()) End Sub End Class End Namespace
System.Object
GrapeCity.Win.CalendarGrid.CalendarView
GrapeCity.Win.CalendarGrid.CalendarListView
GrapeCity.Win.CalendarGrid.CalendarMonthMultiColumnView
GrapeCity.Win.CalendarGrid.CalendarMonthView
GrapeCity.Win.CalendarGrid.CalendarWeekView