PowerTools PlusPak for Windows Forms 8.0J
SpinUp イベント
使用例 

スピンボタンの上矢印がクリックされたときに発生します。
構文
Public Event SpinUp As EventHandler
public event EventHandler SpinUp
使用例

次のサンプルコードは、SpinButtonのアップボタンが押されたときに、SpinUpイベントを使用してタスクを実行する方法を示します。この例では、SpinUpイベントに接続されたイベントハンドラで、listBox1の選択されたインデックスを減少させています。

このサンプルコードは、GrapeCity.Win.Containers.GcComboFrameクラスの概要に示されている詳細なコード例の一部を抜粋したものです。その元の例では、最初にcomboBox1からSpinButton項目を選択してgcComboFrame1にSpinButtonを表示し、次にそのSpinButtonをスピンアップまたはスピンダウンできます。

// Returns a SpinButton instance for gcComboFrame1.
private SideButtonBase CreateSpinButton()
{
    SpinButton spinButton = new SpinButton();

    // Specify a unique name for this button.
    spinButton.Name = "SpinButton";

    // Set the Interval for spinButton.
    spinButton.Interval = 100;

    spinButton.SpinUp += new EventHandler(SpinButton_SpinUp);
    spinButton.SpinDown += new EventHandler(SpinButton_SpinDown);

    // Not show spinButton in gcComboFrame1.
    spinButton.Visible = ButtonVisibility.NotShown;

    return spinButton;
}

// Increase the seleced index of listBox1 when spin is down.
private void SpinButton_SpinDown(object sender, EventArgs e)
{
    if (this.listBox1.SelectedIndex < this.listBox1.Items.Count - 1)
    {
        this.listBox1.SelectedIndex += 1;
    }
    else
    {
        this.listBox1.SelectedIndex = this.listBox1.Items.Count - 1;
    }

    this.textBox1.Text = this.listBox1.SelectedItem.ToString();
}

// Decrease the seleced index of listBox1 when spin is down.
private void SpinButton_SpinUp(object sender, EventArgs e)
{
    if (this.listBox1.SelectedIndex > 0)
    {
        this.listBox1.SelectedIndex -= 1;
    }
    else
    {
        this.listBox1.SelectedIndex = 0;
    }
    this.textBox1.Text = this.listBox1.SelectedItem.ToString();
}
プラットフォーム

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

参照

SpinButton クラス
SpinButton メンバ

Send Feedback