PSHostUserInterface.PromptForChoice Method
Provides a set of choices that enable the user to choose a single option from a set of options.


Namespace: System.Management.Automation.Host
Assembly: System.Management.Automation (in system.management.automation.dll)
Usage

Dim instance As PSHostUserInterface
Dim caption As String
Dim message As String
Dim choices As Collection(Of ChoiceDescription)
Dim defaultChoice As Integer
Dim returnValue As Integer

returnValue = instance.PromptForChoice(caption, message, choices, defaultChoice)
Syntax

Visual Basic
Public MustOverride Function PromptForChoice ( _
    caption As String, _
    message As String, _
    choices As Collection(Of ChoiceDescription), _
    defaultChoice As Integer _
) As Integer
C#
public abstract int PromptForChoice (
    string caption,
    string message,
    Collection<ChoiceDescription> choices,
    int defaultChoice
)
C++
public:
virtual int PromptForChoice (
    String^ caption, 
    String^ message, 
    Collection<ChoiceDescription^>^ choices, 
    int defaultChoice
) abstract
J#
public abstract int PromptForChoice (
    String caption, 
    String message, 
    Collection<ChoiceDescription> choices, 
    int defaultChoice
)
JScript
public abstract function PromptForChoice (
    caption : String, 
    message : String, 
    choices : Collection<ChoiceDescription>, 
    defaultChoice : int
) : int

Parameters

caption

Text that precedes (a title) the choices.

message

A message that describes the choice.

choices

A collection of ChoiceDescription objects that describe each choice.

defaultChoice

The index of the label in the Choices parameter collection. These elements are displayed to the user as the default choices. To indicate no default choice, set to -1.

Return Value

The index of the Choices parameter collection element that corresponds to the option that is selected by the user.
Remarks

To provide a set of choices that allow the user to select multiple choices, implement the IHostUISupportsMultipleChoiceSelection interface.


Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms

Development Platforms

Windows Server 2008, Windows Vista, Windows Server 2003, Windows XP, Windows 7, Windows 2008 R2

Target Platforms

Windows Server 2008, Windows Server 2003, Windows Vista, Windows XP, Windows 7, Windows 2008 R2
See Also

Page view tracker