FileDialog.FilterIndex プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As FileDialog Dim value As Integer value = instance.FilterIndex instance.FilterIndex = value
/** @property */ public int get_FilterIndex () /** @property */ public void set_FilterIndex (int value)
ファイル ダイアログ ボックスで現在選択されているフィルタのインデックスを含む値。既定値は、1 です。

ユーザーに最初に表示するフィルタ処理オプションを設定するには、FilterIndex プロパティを使用します。また、ファイル ダイアログ ボックスを表示した後でも、FilterIndex の値を使用すると、選択されたフィルタに応じて特別なファイル処理を実行できます。
![]() |
---|

FileDialog の OpenFileDialog 実装を使用し、ダイアログ ボックスの作成、そのプロパティの設定、およびダイアログ ボックスの表示を実行するコード例を次に示します。この例では、Filter プロパティと FilterIndex プロパティを使用して、表示するフィルタのリストを指定しています。この例では、フォームに Button が配置されており、System.IO 名前空間が追加されている必要があります。
Private Sub button1_Click(sender As Object, e As System.EventArgs) Dim myStream As Stream Dim openFileDialog1 As New OpenFileDialog() openFileDialog1.InitialDirectory = "c:\" openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" openFileDialog1.FilterIndex = 2 openFileDialog1.RestoreDirectory = True If openFileDialog1.ShowDialog() = DialogResult.OK Then myStream = openFileDialog1.OpenFile() If Not (myStream Is Nothing) Then ' Insert code to read the stream here. myStream.Close() End If End If End Sub
private void button1_Click(object sender, System.EventArgs e) { Stream myStream; OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = "c:\\" ; openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ; openFileDialog1.FilterIndex = 2 ; openFileDialog1.RestoreDirectory = true ; if(openFileDialog1.ShowDialog() == DialogResult.OK) { if((myStream = openFileDialog1.OpenFile())!= null) { // Insert code to read the stream here. myStream.Close(); } } }
private: void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ ) { Stream^ myStream; OpenFileDialog^ openFileDialog1 = gcnew OpenFileDialog; openFileDialog1->InitialDirectory = "c:\\"; openFileDialog1->Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; openFileDialog1->FilterIndex = 2; openFileDialog1->RestoreDirectory = true; if ( openFileDialog1->ShowDialog() == ::DialogResult::OK ) { if ( (myStream = openFileDialog1->OpenFile()) != nullptr ) { // Insert code to read the stream here. myStream->Close(); } } }
protected void button1_Click(Object sender, System.EventArgs e) { Stream myStream; OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.set_InitialDirectory("c:\\"); openFileDialog1.set_Filter( "txt files (*.txt)|*.txt|All files (*.*)|*.*"); openFileDialog1.set_FilterIndex(2); openFileDialog1.set_RestoreDirectory(true); if (openFileDialog1.ShowDialog().Equals(get_DialogResult().OK)) { if ((myStream = openFileDialog1.OpenFile()) != null) { // Insert code to read the stream here. myStream.Close(); } } } //button1_Click

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からFileDialog.FilterIndex プロパティを検索する場合は、下記のリンクをクリックしてください。

- FileDialog.FilterIndex プロパティのページへのリンク