Share via


ListBox.SelectAll 方法

定義

選取 ListBox 控制項中的所有專案。

public:
 virtual void SelectAll() = SelectAll;
void SelectAll();
public void SelectAll();
function selectAll()
Public Sub SelectAll ()

範例

if (listBox.SelectionMode != SelectionMode.Single)
{
    listBox.SelectAll();
}
if (listBox().SelectionMode() != Windows::UI::Xaml::Controls::SelectionMode::Single)
{
    listBox().SelectAll();
}
if (listBox->SelectionMode != SelectionMode::Single)
{
    listBox->SelectAll();
}
If listBox.SelectionMode <> SelectionMode.Single Then
    listBox.SelectAll()
End If

備註

警告

只有在 SelectionMode 屬性設定為 MultipleExtended時,才應該呼叫 SelectAll 方法。 如果 SelectionModeSingle時呼叫 SelectAll,則會擲回例外狀況。

適用於