0

現在、checkedListBox を含む powershell GUI を使用しています。私がやろうとしているのは、特定のチェックボックスがオンになっている場合、他のチェックボックスがオフになっていることを確認することです。powershellでこれを行う方法を知っている人はいますか?

4

1 に答える 1

1

関数を CheckedListBox にアタッチする必要があります。ItemCheckedイベント。

## build a function to handle the ItemChecked event
function Handle-ItemChecked($sender, $args)
{
    ## do something here to change the state of the other
    ## checkbox. the box the user clicked is passed in 
    ## through $args. (See [ItemCheckEventArgs][2] on MSDN)
}

## listen for the event
$form.checkedListBox1.add_ItemChecked({ Handle-ItemChecked })

ハンドラー コードがそれほど複雑でない場合は、別の関数を宣言するのではなく、おそらく { } 内に配置できます。ただし、上記のアプローチの方が読みやすいと思います。

于 2013-06-06T05:03:45.317 に答える