PowerTools MultiRow for Windows Forms 8.0J
GcDateTimeCell クラス
メンバ  使用例 

GcDateTimeCellを表します。
構文
Public Class GcDateTimeCell 
   Inherits FieldsEditorCell
public class GcDateTimeCell : FieldsEditorCell 
解説
GcDateTimeCellを使用すると、機能的な日時入力インタフェースを迅速かつ効率的に設計できます。
使用例
以下のサンプルコードは GcDateTimeCell の使用例です。
using System;
using System.Windows.Forms;
using System.Drawing;

namespace GrapeCity.Win.MultiRow.InputMan.SampleCode
{
    class GcDateTimeCellDemo : Form
    {
        private GcMultiRow gcMultiRow1 = new GcMultiRow();
        private Label label = new Label();

        public GcDateTimeCellDemo()
        {
            this.Text = "GcDateTimeCell Demo";
            this.Size = new Size(350, 300);

            // Add MultiRow to form
            this.gcMultiRow1.Dock = DockStyle.Fill;
            this.Controls.Add(this.gcMultiRow1);

            this.label.Dock = DockStyle.Bottom;
            this.label.Height = 50;
            this.label.BackColor = SystemColors.Info;
            this.label.Text = " Enter edit mode, hit CTR+N to set value to DateTime.Now, you can use the CTR+Left/Right to move cursor between fields, and click the SpinButton to modify the each field value;";
            this.Controls.Add(label);

            this.Load += new EventHandler(Form1_Load);

            this.StartPosition = FormStartPosition.CenterScreen;
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            GcDateTimeCell gcDateTimeCell1 = new GcDateTimeCell();
            gcDateTimeCell1.Size = new Size(130, 21);
            SetGcDateTimeCellDisplayFields(gcDateTimeCell1);
            SetGcDateTimeCellFields(gcDateTimeCell1);
            SetShortcutsAndSideButtons(gcDateTimeCell1);
            Template template1 = Template.CreateGridTemplate(new Cell[] { gcDateTimeCell1, gcDateTimeCell1.Clone() as Cell }, 260,
                AutoGenerateGridTemplateStyles.ColumnHeader | AutoGenerateGridTemplateStyles.RowHeaderAutoNumber);

            gcMultiRow1.Template = template1;
            gcMultiRow1.RowCount = 3;
        }

        private void SetGcDateTimeCellFields(GcDateTimeCell gcDateTimeCell)
        {
            gcDateTimeCell.Fields.Clear();

            DateYearField fields0 = new DateYearField();
            DateLiteralField fields1 = new DateLiteralField();
            DateMonthField fields2 = new DateMonthField();
            DateLiteralField fields3 = new DateLiteralField();
            DateDayField fields4 = new DateDayField();
            DateLiteralField fields5 = new DateLiteralField();
            DateHourField fields6 = new DateHourField();
            DateLiteralField fields7 = new DateLiteralField();
            DateMinuteField fields8 = new DateMinuteField();
            DateLiteralField fields9 = new DateLiteralField();
            DateSecondField fields10 = new DateSecondField();
            fields1.Text = "/";
            fields3.Text = "/";
            fields7.Text = ":";
            fields9.Text = ":";
            gcDateTimeCell.Fields.AddRange(new DateField[]{
                fields0,fields1,fields2,fields3,fields4,fields5,fields6,fields7,fields8,fields9,fields10,
            });
        }

        private void SetGcDateTimeCellDisplayFields(GcDateTimeCell gcDateTimeCell1)
        {
            gcDateTimeCell1.DisplayFields.Clear();

            DateYearDisplayField dateYearDisplayField1 = new DateYearDisplayField();
            DateLiteralDisplayField dateLiteralDisplayField2 = new DateLiteralDisplayField();
            DateMonthDisplayField dateMonthDisplayField1 = new DateMonthDisplayField();
            DateLiteralDisplayField dateLiteralDisplayField3 = new DateLiteralDisplayField();
            DateDayDisplayField dateDayDisplayField1 = new DateDayDisplayField();
            DateLiteralDisplayField dateLiteralDisplayField4 = new DateLiteralDisplayField();
            DateLiteralDisplayField dateLiteralDisplayField5 = new DateLiteralDisplayField();
            DateHourDisplayField dateHourDisplayField6 = new DateHourDisplayField();
            DateLiteralDisplayField dateLiteralDisplayField7 = new DateLiteralDisplayField();
            DateMinuteDisplayField dateMinuteDisplayField8 = new DateMinuteDisplayField();
            DateLiteralDisplayField dateLiteralDisplayField9 = new DateLiteralDisplayField();
            DateSecondDisplayField dateSecondDisplayField10 = new DateSecondDisplayField();

            dateLiteralDisplayField2.Text = "年";
            dateLiteralDisplayField3.Text = "月";
            dateLiteralDisplayField4.Text = "日";
            dateLiteralDisplayField7.Text = ":";
            dateLiteralDisplayField9.Text = ":";

            gcDateTimeCell1.DisplayFields.AddRange(new DateDisplayField[] {
            dateYearDisplayField1,dateLiteralDisplayField2,dateMonthDisplayField1,dateLiteralDisplayField3,dateDayDisplayField1,dateLiteralDisplayField4,
            dateLiteralDisplayField5,dateHourDisplayField6,dateLiteralDisplayField7,dateMinuteDisplayField8,dateLiteralDisplayField9,dateSecondDisplayField10});
        }

        private void SetShortcutsAndSideButtons(GcDateTimeCell gcDateTimeCell1)
        {
            //In edit mode, hit the CTR+N to set date to DateTime.Now
            gcDateTimeCell1.ShortcutKeys.Add(Keys.Control | Keys.N, "SetNow");
            //In edit mode, hit the CTR+Right to move to next field, if arrive last field, then jump to next Cell.
            gcDateTimeCell1.ShortcutKeys.Add(Keys.Control | Keys.Right, "NextFieldThenCell");
            //In edit mode, hit the CTR+Left to move to previous field, if arrive first field, then jump to previous Cell.
            gcDateTimeCell1.ShortcutKeys.Add(Keys.Control | Keys.Left, "PreviousFieldThenCell");

            gcDateTimeCell1.SideButtons.Clear();
            gcDateTimeCell1.SideButtons.Add(new SpinButton());
        }

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

Namespace GrapeCity.Win.MultiRow.InputMan.SampleCode
    Class GcDateTimeCellDemo
        Inherits Form
        Private gcMultiRow1 As New GcMultiRow()
        Private label As New Label()

        Public Sub New()
            Me.Text = "GcDateTimeCell Demo"
            Me.Size = New Size(350, 300)

            ' Add MultiRow to form
            Me.gcMultiRow1.Dock = DockStyle.Fill
            Me.Controls.Add(Me.gcMultiRow1)

            Me.label.Dock = DockStyle.Bottom
            Me.label.Height = 50
            Me.label.BackColor = SystemColors.Info
            Me.label.Text = " Enter edit mode, hit CTR+N to set value to DateTime.Now, you can use the CTR+Left/Right to move cursor between fields, and click the SpinButton to modify the each field value;"
            Me.Controls.Add(label)

            Me.StartPosition = FormStartPosition.CenterScreen
        End Sub
        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
            Dim gcDateTimeCell1 As New GcDateTimeCell()
            gcDateTimeCell1.Size = New Size(130, 21)
            SetGcDateTimeCellDisplayFields(gcDateTimeCell1)
            SetGcDateTimeCellFields(gcDateTimeCell1)
            SetShortcutsAndSideButtons(gcDateTimeCell1)
            Dim template1 As Template = Template.CreateGridTemplate(New Cell() {gcDateTimeCell1, TryCast(gcDateTimeCell1.Clone(), Cell)}, 260, AutoGenerateGridTemplateStyles.ColumnHeader Or AutoGenerateGridTemplateStyles.RowHeaderAutoNumber)

            gcMultiRow1.Template = template1
            gcMultiRow1.RowCount = 3
        End Sub

        Private Sub SetGcDateTimeCellFields(ByVal gcDateTimeCell As GcDateTimeCell)
            gcDateTimeCell.Fields.Clear()

            Dim fields0 As New DateYearField()
            Dim fields1 As New DateLiteralField()
            Dim fields2 As New DateMonthField()
            Dim fields3 As New DateLiteralField()
            Dim fields4 As New DateDayField()
            Dim fields5 As New DateLiteralField()
            Dim fields6 As New DateHourField()
            Dim fields7 As New DateLiteralField()
            Dim fields8 As New DateMinuteField()
            Dim fields9 As New DateLiteralField()
            Dim fields10 As New DateSecondField()
            fields1.Text = "/"
            fields3.Text = "/"
            fields7.Text = ":"
            fields9.Text = ":"
            gcDateTimeCell.Fields.AddRange(New DateField() {fields0, fields1, fields2, fields3, fields4, fields5, _
             fields6, fields7, fields8, fields9, fields10})
        End Sub

        Private Sub SetGcDateTimeCellDisplayFields(ByVal gcDateTimeCell1 As GcDateTimeCell)
            gcDateTimeCell1.DisplayFields.Clear()

            Dim dateYearDisplayField1 As New DateYearDisplayField()
            Dim dateLiteralDisplayField2 As New DateLiteralDisplayField()
            Dim dateMonthDisplayField1 As New DateMonthDisplayField()
            Dim dateLiteralDisplayField3 As New DateLiteralDisplayField()
            Dim dateDayDisplayField1 As New DateDayDisplayField()
            Dim dateLiteralDisplayField4 As New DateLiteralDisplayField()
            Dim dateLiteralDisplayField5 As New DateLiteralDisplayField()
            Dim dateHourDisplayField6 As New DateHourDisplayField()
            Dim dateLiteralDisplayField7 As New DateLiteralDisplayField()
            Dim dateMinuteDisplayField8 As New DateMinuteDisplayField()
            Dim dateLiteralDisplayField9 As New DateLiteralDisplayField()
            Dim dateSecondDisplayField10 As New DateSecondDisplayField()

            dateLiteralDisplayField2.Text = "年"
            dateLiteralDisplayField3.Text = "月"
            dateLiteralDisplayField4.Text = "日"
            dateLiteralDisplayField7.Text = ":"
            dateLiteralDisplayField9.Text = ":"

            gcDateTimeCell1.DisplayFields.AddRange(New DateDisplayField() {dateYearDisplayField1, dateLiteralDisplayField2, dateMonthDisplayField1, dateLiteralDisplayField3, dateDayDisplayField1, dateLiteralDisplayField4, _
             dateLiteralDisplayField5, dateHourDisplayField6, dateLiteralDisplayField7, dateMinuteDisplayField8, dateLiteralDisplayField9, dateSecondDisplayField10})
        End Sub

        Private Sub SetShortcutsAndSideButtons(ByVal gcDateTimeCell1 As GcDateTimeCell)
            'In edit mode, hit the CTR+N to set date to DateTime.Now
            gcDateTimeCell1.ShortcutKeys.Add(Keys.Control Or Keys.N, "SetNow")
            'In edit mode, hit the CTR+Right to move to next field, if arrive last field, then jump to next Cell.
            gcDateTimeCell1.ShortcutKeys.Add(Keys.Control Or Keys.Right, "NextFieldThenCell")
            'In edit mode, hit the CTR+Left to move to previous field, if arrive first field, then jump to previous Cell.
            gcDateTimeCell1.ShortcutKeys.Add(Keys.Control Or Keys.Left, "PreviousFieldThenCell")

            gcDateTimeCell1.SideButtons.Clear()
            gcDateTimeCell1.SideButtons.Add(New SpinButton())
        End Sub

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

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         GrapeCity.Win.MultiRow.Cell
            GrapeCity.Win.MultiRow.InputMan.InputManCellBase
               GrapeCity.Win.MultiRow.InputMan.FieldsEditorCell
                  GrapeCity.Win.MultiRow.InputMan.GcDateTimeCell

参照

GcDateTimeCell メンバ
GrapeCity.Win.MultiRow.InputMan 名前空間

 

 


© 2008-2015 GrapeCity inc. All rights reserved.