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

GcMaskCell内のGcMaskコントロールを表します。
構文
Public Class GcMaskEditingControl 
   Inherits GrapeCity.Win.Editors.GcMask
   Implements GrapeCity.Win.MultiRow.IEditingControl 
public class GcMaskEditingControl : GrapeCity.Win.Editors.GcMask, GrapeCity.Win.MultiRow.IEditingControl  
解説

GcMaskEditingControlクラスはGrapeCity.Win.MultiRow.IEditingControlインタフェースを実装する特殊化されたGcMask で、セルが編集モードのときにCell内でホストできます。GcMaskEditingControlは、Cellが編集モードのときに、GrapeCity.Win.MultiRow.GcMultiRowコントロールのGrapeCity.Win.MultiRow.GcMultiRow.EditingControlプロパティを通じて取得できます。

セルが編集モードに入るときに編集コントロールを独自に初期化する場合は、GrapeCity.Win.MultiRow.GcMultiRow.EditingControlShowingイベントを処理します。編集コントロールの表示特性をカスタマイズするには、GrapeCity.Win.MultiRow.EditingControlShowingEventArgs.Controlプロパティによって返されたコントロールのプロパティを設定するのではなく、GrapeCity.Win.MultiRow.EditingControlShowingEventArgs.CellStyleプロパティによって返されたオブジェクトのプロパティを設定します。

使用例
次のコードは GcMaskEditingControl の使用例です。
using System;
using System.Windows.Forms;
using System.Drawing;
using GrapeCity.Win.Editors;

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

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

            // Add MultiRow to form
            this.gcMultiRow1.Dock = DockStyle.Fill;
            this.gcMultiRow1.EditMode = EditMode.EditOnEnter;
            this.gcMultiRow1.EditingControlShowing += new EventHandler<EditingControlShowingEventArgs>(gcMultiRow1_EditingControlShowing);
            this.Controls.Add(this.gcMultiRow1);

            this.label.Dock = DockStyle.Bottom;
            this.label.Height = 30;
            this.label.BackColor = SystemColors.Info;
            this.label.Text = "In edit mode, hit the CTR + Left/Right to move the active field, one animation effect will show.";
            this.Controls.Add(label);

            this.Load += new EventHandler(Form1_Load);

            this.StartPosition = FormStartPosition.CenterScreen;
        }

        private void gcMultiRow1_EditingControlShowing(object sender, EditingControlShowingEventArgs e)
        {
            GcMask gcMask1 = e.Control as GcMask;

            gcMask1.FieldEnter -= new EventHandler<FieldEventArgs>(gcMask1_FieldEnter);
            gcMask1.FieldEnter += new EventHandler<FieldEventArgs>(gcMask1_FieldEnter);

            gcMask1.FieldLeave -= new EventHandler<FieldEventArgs>(gcMask1_FieldLeave);
            gcMask1.FieldLeave += new EventHandler<FieldEventArgs>(gcMask1_FieldLeave);
        }

        void gcMask1_FieldLeave(object sender, FieldEventArgs e)
        {
            e.Field.Font = new Font(e.Field.Font.FontFamily, e.Field.Font.Size - 6);
            e.Field.ForeColor = SystemColors.WindowText;
        }

        void gcMask1_FieldEnter(object sender, FieldEventArgs e)
        {
            e.Field.Font = new Font(e.Field.Font.FontFamily, e.Field.Font.Size + 6);
            e.Field.ForeColor = Color.Red;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            GcMaskCell gcMaskCell1 = new GcMaskCell();
            SetGcMaskCellFields(gcMaskCell1);
            gcMaskCell1.Size = new Size(120, 40);
            gcMaskCell1.Value = "1234567";
            Template template1 = Template.CreateGridTemplate(new Cell[] { gcMaskCell1 }, 160,
                AutoGenerateGridTemplateStyles.ColumnHeader | AutoGenerateGridTemplateStyles.RowHeaderAutoNumber);

            gcMultiRow1.Template = template1;
            gcMultiRow1.RowCount = 3;
        }
        private void SetGcMaskCellFields(GcMaskCell gcMaskCell1)
        {
            gcMaskCell1.Fields.Clear();

            MaskPatternField maskPatternField1 = new MaskPatternField();
            MaskLiteralField maskLiteralField1 = new MaskLiteralField();
            MaskPatternField maskPatternField2 = new MaskPatternField();

            maskPatternField1.MaxLength = 3;
            maskPatternField1.MinLength = 3;
            maskPatternField1.Pattern = "\\D";
            maskLiteralField1.Text = "-";
            maskPatternField2.MaxLength = 4;
            maskPatternField2.MinLength = 4;
            maskPatternField2.Pattern = "\\D";

            gcMaskCell1.Fields.AddRange(new MaskField[] { maskPatternField1, maskLiteralField1, maskPatternField2 });
        }
        [STAThreadAttribute()]
        public static void Main()
        {
            Application.EnableVisualStyles();
            Application.Run(new GcMaskCellEditingControlDemo());
        }
    }
}
Imports System
Imports System.Windows.Forms
Imports System.Drawing
Imports GrapeCity.Win.Editors

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

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

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

            Me.label.Dock = DockStyle.Bottom
            Me.label.Height = 30
            Me.label.BackColor = SystemColors.Info
            Me.label.Text = "In edit mode, hit the CTR + Left/Right to move the active field, one animation effect will show."
            Me.Controls.Add(label)

            Me.StartPosition = FormStartPosition.CenterScreen
        End Sub

        Private Sub gcMultiRow1_EditingControlShowing(ByVal sender As Object, ByVal e As EditingControlShowingEventArgs) Handles gcMultiRow1.EditingControlShowing
            Dim gcMask1 As GcMask = TryCast(e.Control, GcMask)

            RemoveHandler gcMask1.FieldEnter, AddressOf gcMask1_FieldEnter
            AddHandler gcMask1.FieldEnter, AddressOf gcMask1_FieldEnter

            RemoveHandler gcMask1.FieldLeave, AddressOf gcMask1_FieldLeave
            AddHandler gcMask1.FieldLeave, AddressOf gcMask1_FieldLeave
        End Sub

        Private Sub gcMask1_FieldLeave(ByVal sender As Object, ByVal e As FieldEventArgs)
            e.Field.Font = New Font(e.Field.Font.FontFamily, e.Field.Font.Size - 6)
            e.Field.ForeColor = SystemColors.WindowText
        End Sub

        Private Sub gcMask1_FieldEnter(ByVal sender As Object, ByVal e As FieldEventArgs)
            e.Field.Font = New Font(e.Field.Font.FontFamily, e.Field.Font.Size + 6)
            e.Field.ForeColor = Color.Red
        End Sub

        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
            Dim gcMaskCell1 As New GcMaskCell()
            SetGcMaskCellFields(gcMaskCell1)
            gcMaskCell1.Size = New Size(120, 40)
            gcMaskCell1.Value = "1234567"
            Dim template1 As Template = Template.CreateGridTemplate(New Cell() {gcMaskCell1}, 160, AutoGenerateGridTemplateStyles.ColumnHeader Or AutoGenerateGridTemplateStyles.RowHeaderAutoNumber)

            gcMultiRow1.Template = template1
            gcMultiRow1.RowCount = 3
        End Sub
        Private Sub SetGcMaskCellFields(ByVal gcMaskCell1 As GcMaskCell)
            gcMaskCell1.Fields.Clear()

            Dim maskPatternField1 As New MaskPatternField()
            Dim maskLiteralField1 As New MaskLiteralField()
            Dim maskPatternField2 As New MaskPatternField()

            maskPatternField1.MaxLength = 3
            maskPatternField1.MinLength = 3
            maskPatternField1.Pattern = "\D"
            maskLiteralField1.Text = "-"
            maskPatternField2.MaxLength = 4
            maskPatternField2.MinLength = 4
            maskPatternField2.Pattern = "\D"

            gcMaskCell1.Fields.AddRange(New MaskField() {maskPatternField1, maskLiteralField1, maskPatternField2})
        End Sub
        <STAThreadAttribute()> _
        Public Shared Sub Main()
            Application.EnableVisualStyles()
            Application.Run(New GcMaskCellEditingControlDemo())
        End Sub
    End Class
End Namespace
継承階層

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         System.Windows.Forms.Control
            GrapeCity.Framework.Forms.FrameworkControl
               GrapeCity.Framework.Views.Windows.ElementContainerControl
                  GrapeCity.Framework.Forms.ControlBase
                              GrapeCity.Win.MultiRow.InputMan.GcMaskEditingControl

参照

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

 

 


© 2008-2015 GrapeCity inc. All rights reserved.