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

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

GcCharMaskEditingControlクラスはGrapeCity.Win.MultiRow.IEditingControlインタフェースを実装する特殊化されたGcCharMask で、セルが編集モードのときにCell内でホストできます。GcCharMaskEditingControlは、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プロパティによって返されたオブジェクトのプロパティを設定します。

使用例
以下のサンプルコードは GcCharMaskEditingControlの使用例です。
using System;
using System.Windows.Forms;
using System.Drawing;
using GrapeCity.Win.Editors;

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

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

            // Add MultiRow to form
            this.gcMultiRow1.Dock = DockStyle.Fill;
            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 = "Input some text in char box, the backcolor will change.";
            this.Controls.Add(label);

            this.Load += new EventHandler(Form1_Load);

            this.StartPosition = FormStartPosition.CenterScreen;
        }

        private void gcMultiRow1_EditingControlShowing(object sender, EditingControlShowingEventArgs e)
        {
            HighLightBox(e.Control, EventArgs.Empty);
            e.Control.TextChanged -= new EventHandler(HighLightBox);
            e.Control.TextChanged += new EventHandler(HighLightBox);
        }

        void HighLightBox(object sender, EventArgs e)
        {
            GcCharMask charMask = sender as GcCharMask;
            for (int i = 0; i < charMask.CharBoxes.Count; i++)
            {
                if (i < charMask.Text.Length)
                {
                    charMask.CharBoxes[i].BackColor = Color.Red;
                }
                else
                {
                    charMask.CharBoxes[i].BackColor = Color.Lime;
                }
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            GcCharMaskCell gcCharMaskCell1 = new GcCharMaskCell();
            gcCharMaskCell1.Size = new Size(155, 40);
            Template template1 = Template.CreateGridTemplate(new Cell[] { gcCharMaskCell1 }, 160,
                AutoGenerateGridTemplateStyles.ColumnHeader | AutoGenerateGridTemplateStyles.RowHeaderAutoNumber);

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

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

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

        Public Sub New()
            Me.Text = "GcCharMaskCellEditingControl 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 = 30
            Me.label.BackColor = SystemColors.Info
            Me.label.Text = "Input some text in char box, the backcolor will change."
            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
            HighLightBox(e.Control, EventArgs.Empty)
            RemoveHandler e.Control.TextChanged, AddressOf Me.HighLightBox
            AddHandler e.Control.TextChanged, AddressOf Me.HighLightBox

        End Sub

        Private Sub HighLightBox(ByVal sender As Object, ByVal e As EventArgs)
            Dim charMask As GcCharMask = TryCast(sender, GcCharMask)

            For index As Integer = 0 To charMask.CharBoxes.Count - 1
                If index < charMask.Text.Length Then
                    charMask.CharBoxes(index).BackColor = Color.Red
                Else
                    charMask.CharBoxes(index).BackColor = Color.Lime
                End If
            Next

        End Sub

        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
            Dim gcCharMaskCell1 As New GcCharMaskCell()
            gcCharMaskCell1.Size = New Size(155, 40)
            Dim template1 As Template = Template.CreateGridTemplate(New Cell() {gcCharMaskCell1}, 160, AutoGenerateGridTemplateStyles.ColumnHeader Or AutoGenerateGridTemplateStyles.RowHeaderAutoNumber)

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

        <STAThreadAttribute()> _
        Public Shared Sub Main()
            Application.EnableVisualStyles()
            Application.Run(New GcCharMaskCellEditingControlDemo())
        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.GcCharMaskEditingControl

参照

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

 

 


© 2008-2015 GrapeCity inc. All rights reserved.