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

選択肢のリストからテキスト文字列を表示および設定するCellを表します。文字列を選択するには、上下ボタンをクリックしてリスト内を移動するか、[↑]および[↓]キーを押すか、リストの項目に一致する文字列を入力します。
構文
Public Class DomainUpDownCell 
   Inherits Cell
public class DomainUpDownCell : Cell 
解説

DomainUpDownCellクラスは、選択肢のリストからテキスト文字列を表示および設定する特別なタイプのCellです。文字列を選択するには、上下ボタンをクリックしてリスト内を移動するか、[↑]および[↓]キーを押すか、リストの項目に一致する文字列を入力します。

DomainUpDownCellはリストボックスやコンボボックスに似ていますが、必要なスペースが少なくて済みます。

継承時の注意:

DomainUpDownCellから継承した派生クラスに新しいプロパティを追加するときは、必ずCloneメソッドをオーバーライドして、クローニング操作時に新しいプロパティがコピーされるようにしてください。また、基本クラスのCloneメソッドを呼び出して、基本クラスのプロパティが新しいセルにコピーされるようにしてください。

使用例
次のサンプルコードは、DomainUpDownCellの使用方法を示します。
using System;
using System.Windows.Forms;
using System.Drawing;

namespace GrapeCity.Win.MultiRow.SampleCode
{
    public class DomainUpDownCellDemo : Form
    {
        private GcMultiRow gcMultiRow1 = new GcMultiRow();
        private FlowLayoutPanel panel = new FlowLayoutPanel();

        public DomainUpDownCellDemo()
        {
            this.Text = "DomainUpDownCell Demo";
            this.Size = new Size(450, 350);

            // Initial flow layout panel and add to form.
            this.panel.Dock = DockStyle.Left;
            this.panel.Size = new Size(200, 200);
            this.panel.FlowDirection = FlowDirection.TopDown;
            this.panel.WrapContents = false;
            this.panel.Padding = new Padding(5);
            this.Controls.Add(panel);

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

            label.Height = 50;
            label.Dock = DockStyle.Bottom;
            label.BackColor = SystemColors.Info;
            label.Text = "Please Click one button to set the corresponding Property.";
            this.Controls.Add(label);

            this.Load += new EventHandler(Form1_Load);

            InitButton();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            DomainUpDownCell domainUpDownCell1 = new DomainUpDownCell();
            domainUpDownCell1.Items.AddRange(new int[] { 7, 3, 5, 1 });

            Template template1 = Template.CreateGridTemplate(new Cell[] { domainUpDownCell1 });

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

        #region Button Event Handlers

        void setShowSpinButtonButton_Click(object sender, EventArgs e)
        {
            DomainUpDownCell domainUpDownCell1 = this.gcMultiRow1[0, 0] as DomainUpDownCell;
            if (domainUpDownCell1.ShowSpinButton == CellButtonVisibility.ShowAlways||domainUpDownCell1.ShowSpinButton== CellButtonVisibility.ShowForCurrentCell)
            {
                domainUpDownCell1.ShowSpinButton = CellButtonVisibility.NotShown;
            }
            else
            {
                domainUpDownCell1.ShowSpinButton = CellButtonVisibility.ShowAlways;
            }
            label.Text = "Click the button repeatedly, the ShowSpinButton property will take effect.";
        }

        void setUpDownAlignButton_Click(object sender, EventArgs e)
        {
            DomainUpDownCell domainUpDownCell1 = this.gcMultiRow1[0, 0] as DomainUpDownCell;
            domainUpDownCell1.ShowSpinButton = CellButtonVisibility.ShowAlways;

            if (domainUpDownCell1.UpDownAlign == LeftRightAlignment.Left)
            {
                domainUpDownCell1.UpDownAlign = LeftRightAlignment.Right;
            }
            else
            {
                domainUpDownCell1.UpDownAlign = LeftRightAlignment.Left;
            }
            label.Text = "Click the button repeatedly, the UpDownAlign property will take effect.";
        }

        void setSortedButton_Click(object sender, EventArgs e)
        {
            DomainUpDownCell domainUpDownCell1 = this.gcMultiRow1[0, 0] as DomainUpDownCell;

            if (domainUpDownCell1.Sorted)
            {
                //set Sorted property from true to false, the all items' sorted state cannot be restored to unsorted.
                domainUpDownCell1.Sorted = false;
            }
            else
            {
                //set it to true, the all items' will change to the sorted state.
                domainUpDownCell1.Sorted = true;
            }
            label.Text = "Click the button, the all items in the Items (7,3,5,1) property will be sorted to (1,3,5,7)";
        }

        void setWrapButton_Click(object sender, EventArgs e)
        {
            DomainUpDownCell domainUpDownCell1 = this.gcMultiRow1[0, 0] as DomainUpDownCell;

            if (domainUpDownCell1.Wrap)
            {
                //set the Wrap to false, the all items' can not be shown circularly.
                domainUpDownCell1.Wrap = false;
            }
            else
            {
                //set the Wrap to true, the all items' can be shown circularly.
                domainUpDownCell1.Wrap = true;
            }
            label.Text = "Click the button, the all items' can (or cannot) be shown circularly when you click the UpDown button";
        }

        #endregion

        #region Initialize Buttons

        private void InitButton()
        {
            AddButton(setShowSpinButtonButton, "Set ShowSpinButton", new EventHandler(setShowSpinButtonButton_Click));
            AddButton(setUpDownAlignButton, "Set UpDownAlign", new EventHandler(setUpDownAlignButton_Click));
            AddButton(setSortedButton, "Set Sorted", new EventHandler(setSortedButton_Click));
            AddButton(setWrapButton, "Set Wrap", new EventHandler(setWrapButton_Click));
        }

        private void AddButton(Button button, string text, EventHandler eventHandler)
        {
            this.panel.Controls.Add(button);
            button.Text = text;
            button.AutoSize = true;
            button.Click += eventHandler;
        }

        Button setShowSpinButtonButton = new Button();
        Button setUpDownAlignButton = new Button();
        Button setSortedButton = new Button();
        Button setWrapButton = new Button();
        Label label = new Label();

        #endregion

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

Public Class DomainUpDownCellDemo
    Inherits Form
    Private gcMultiRow1 As New GcMultiRow()
    Private panel As New FlowLayoutPanel()

    Public Sub New()
        Me.Text = "DomainUpDownCell Demo"
        Me.Size = New Size(450, 350)

        ' Initial flow layout panel and add to form.
        Me.panel.Dock = DockStyle.Left
        Me.panel.Size = New Size(200, 200)
        Me.panel.FlowDirection = FlowDirection.TopDown
        Me.panel.WrapContents = False
        Me.panel.Padding = New Padding(5)
        Me.Controls.Add(panel)

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

        label.Height = 50
        label.Dock = DockStyle.Bottom
        label.BackColor = SystemColors.Info
        label.Text = "Please Click one button to set the corresponding Property."
        Me.Controls.Add(label)

        InitButton()
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        Dim domainUpDownCell1 As New DomainUpDownCell()
        domainUpDownCell1.Items.AddRange(New Integer() {7, 3, 5, 1})

        Dim template1 As Template = Template.CreateGridTemplate(New Cell() {domainUpDownCell1})

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

#Region "Button Event Handlers"

    Private Sub setShowSpinButtonButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setShowSpinButtonButton.Click
        Dim domainUpDownCell1 As DomainUpDownCell = TryCast(Me.gcMultiRow1(0, 0), DomainUpDownCell)
        If domainUpDownCell1.ShowSpinButton = CellButtonVisibility.ShowAlways OrElse domainUpDownCell1.ShowSpinButton = CellButtonVisibility.ShowForCurrentCell Then
            domainUpDownCell1.ShowSpinButton = CellButtonVisibility.NotShown
        Else
            domainUpDownCell1.ShowSpinButton = CellButtonVisibility.ShowAlways
        End If
        label.Text = "Click the button repeatedly, the ShowSpinButton property will take effect."
    End Sub

    Private Sub setUpDownAlignButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setUpDownAlignButton.Click
        Dim domainUpDownCell1 As DomainUpDownCell = TryCast(Me.gcMultiRow1(0, 0), DomainUpDownCell)
        domainUpDownCell1.ShowSpinButton = CellButtonVisibility.ShowAlways

        If domainUpDownCell1.UpDownAlign = LeftRightAlignment.Left Then
            domainUpDownCell1.UpDownAlign = LeftRightAlignment.Right
        Else
            domainUpDownCell1.UpDownAlign = LeftRightAlignment.Left
        End If
        label.Text = "Click the button repeatedly, the UpDownAlign property will take effect."
    End Sub

    Private Sub setSortedButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setSortedButton.Click
        Dim domainUpDownCell1 As DomainUpDownCell = TryCast(Me.gcMultiRow1(0, 0), DomainUpDownCell)

        If domainUpDownCell1.Sorted Then
            'set Sorted property from true to false, the all items' sorted state cannot be restored to unsorted.
            domainUpDownCell1.Sorted = False
        Else
            'set it to true, the all items' will change to the sorted state.
            domainUpDownCell1.Sorted = True
        End If
        label.Text = "Click the button, the all items in the Items (7,3,5,1) property will be sorted to (1,3,5,7)"
    End Sub

    Private Sub setWrapButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setWrapButton.Click
        Dim domainUpDownCell1 As DomainUpDownCell = TryCast(Me.gcMultiRow1(0, 0), DomainUpDownCell)

        If domainUpDownCell1.Wrap Then
            'set the Wrap to false, the all items' can not be shown circularly.
            domainUpDownCell1.Wrap = False
        Else
            'set the Wrap to true, the all items' can be shown circularly.
            domainUpDownCell1.Wrap = True
        End If
        label.Text = "Click the button, the all items' can (or cannot) be shown circularly when you click the UpDown button"
    End Sub

#End Region

#Region "Initialize Buttons"

    Private Sub InitButton()
        AddButton(setShowSpinButtonButton, "Set ShowSpinButton")
        AddButton(setUpDownAlignButton, "Set UpDownAlign")
        AddButton(setSortedButton, "Set Sorted")
        AddButton(setWrapButton, "Set Wrap")
    End Sub

    Private Sub AddButton(ByVal button As Button, ByVal text As String)
        Me.panel.Controls.Add(button)
        button.Text = text
        button.AutoSize = True
    End Sub

    Friend WithEvents setShowSpinButtonButton As New Button()
    Friend WithEvents setUpDownAlignButton As New Button()
    Friend WithEvents setSortedButton As New Button()
    Friend WithEvents setWrapButton As New Button()
    Private label As New Label()

#End Region

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

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         GrapeCity.Win.MultiRow.Cell
            GrapeCity.Win.MultiRow.DomainUpDownCell

参照

DomainUpDownCell メンバ
GrapeCity.Win.MultiRow 名前空間
Cell クラス
DomainUpDownEditingControl クラス

 

 


© 2008-2015 GrapeCity inc. All rights reserved.