Export (0) Print
Expand All

OpenFileDialog.FilterIndex Property

Silverlight

Gets or sets the index of the selected item in the OpenFileDialog filter drop-down list.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)

public int FilterIndex { get; set; }

Property Value

Type: System.Int32
The index of the selected item in the OpenFileDialog filter drop-down list. The default is 1.

ExceptionCondition
ArgumentOutOfRangeException

The filter index is less than 1.

This index is 1-based.

If you set the FilterIndex property, that filter will be selected when the dialog box is displayed.

The following example shows how to create an OpenFileDialog and set the Filter and FilterIndex properties.


// Create an instance of the open file dialog box.
OpenFileDialog openFileDialog1 = new OpenFileDialog();

// Set filter options and filter index.
openFileDialog1.Filter = "Text Files (.txt)|*.txt|All Files (*.*)|*.*";
openFileDialog1.FilterIndex = 1;


Silverlight

Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft