OpenFileDialog イベント

名前 | 説明 | |
---|---|---|
![]() | Disposed | コンポーネントの Disposed イベントを待機するイベント ハンドラを追加します。 ( Component から継承されます。) |
![]() | FileOk | ファイル ダイアログ ボックスの [開く] ボタンまたは [保存] ボタンをユーザーがクリックすると発生します。 ( FileDialog から継承されます。) |
![]() | HelpRequest | ユーザーがコモン ダイアログ ボックスの [?] ボタンをクリックすると発生します。 ( CommonDialog から継承されます。) |

OpenFileDialog クラス
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


このクラスを使用すると、ファイルが存在するかどうかを確認してから、そのファイルを開くことができます。ShowReadOnly プロパティは、ダイアログ ボックスに読み取り専用チェック ボックスを表示するかどうかを決定します。ReadOnlyChecked プロパティは、読み取り専用チェック ボックスがオンかオフかを示します。
このクラスのほとんどの機能は FileDialog クラスにあります。
ユーザーがファイルではなくフォルダを選択できるようにする場合は、代わりに FolderBrowserDialog を使用します。

OpenFileDialog を作成し、いくつかのプロパティを設定し、CommonDialog.ShowDialog メソッドを使用してダイアログ ボックスを表示するコード例を次に示します。この例では、フォームに 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

System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.CommonDialog
System.Windows.Forms.FileDialog
System.Windows.Forms.OpenFileDialog


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


OpenFileDialog コンストラクタ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)



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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


OpenFileDialog プロパティ


名前 | 説明 | |
---|---|---|
![]() | CanRaiseEvents | コンポーネントがイベントを発生させることがきるかどうかを示す値を取得します。 ( Component から継承されます。) |
![]() | DesignMode | Component が現在デザイン モードかどうかを示す値を取得します。 ( Component から継承されます。) |
![]() | Events | Component に結び付けられているイベント ハンドラのリストを取得します。 ( Component から継承されます。) |

OpenFileDialog メソッド

名前 | 説明 | |
---|---|---|
![]() | CreateObjRef | リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。 ( MarshalByRefObject から継承されます。) |
![]() | Dispose | オーバーロードされます。 Component によって使用されているリソースを解放します。 ( Component から継承されます。) |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetLifetimeService | 対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。 ( MarshalByRefObject から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | InitializeLifetimeService | 対象のインスタンスの有効期間ポリシーを制御する、有効期間サービス オブジェクトを取得します。 ( MarshalByRefObject から継承されます。) |
![]() | OpenFile | ユーザーが選択したファイルを読み取り専用で開きます。このファイルは、FileName プロパティで指定されます。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | Reset | オーバーライドされます。 すべてのプロパティを既定値にリセットします。 |
![]() | ShowDialog | オーバーロードされます。 コモン ダイアログ ボックスを実行します。 ( CommonDialog から継承されます。) |
![]() | ToString | このオブジェクトの文字列形式を示します。 ( FileDialog から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Dispose | オーバーロードされます。 Component によって使用されているリソースを解放します。 ( Component から継承されます。) |
![]() | Finalize | Component がガベージ コレクションによってクリアされる前に、アンマネージ リソースを解放し、その他のクリーンアップ操作を実行します。 ( Component から継承されます。) |
![]() | GetService | Component またはその Container で提供されるサービスを表すオブジェクトを返します。 ( Component から継承されます。) |
![]() | MemberwiseClone | オーバーロードされます。 ( MarshalByRefObject から継承されます。) |

OpenFileDialog メンバ
ユーザーにファイルを開くよう要求します。このクラスは継承できません。
OpenFileDialog データ型で公開されるメンバを以下の表に示します。



名前 | 説明 | |
---|---|---|
![]() | CanRaiseEvents | コンポーネントがイベントを発生させることがきるかどうかを示す値を取得します。(Component から継承されます。) |
![]() | DesignMode | Component が現在デザイン モードかどうかを示す値を取得します。(Component から継承されます。) |
![]() | Events | Component に結び付けられているイベント ハンドラのリストを取得します。(Component から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | CreateObjRef | リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。 (MarshalByRefObject から継承されます。) |
![]() | Dispose | オーバーロードされます。 Component によって使用されているリソースを解放します。 (Component から継承されます。) |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetLifetimeService | 対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。 (MarshalByRefObject から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | InitializeLifetimeService | 対象のインスタンスの有効期間ポリシーを制御する、有効期間サービス オブジェクトを取得します。 (MarshalByRefObject から継承されます。) |
![]() | OpenFile | ユーザーが選択したファイルを読み取り専用で開きます。このファイルは、FileName プロパティで指定されます。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | Reset | オーバーライドされます。 すべてのプロパティを既定値にリセットします。 |
![]() | ShowDialog | オーバーロードされます。 コモン ダイアログ ボックスを実行します。 (CommonDialog から継承されます。) |
![]() | ToString | このオブジェクトの文字列形式を示します。 (FileDialog から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Dispose | オーバーロードされます。 Component によって使用されているリソースを解放します。 (Component から継承されます。) |
![]() | Finalize | Component がガベージ コレクションによってクリアされる前に、アンマネージ リソースを解放し、その他のクリーンアップ操作を実行します。 (Component から継承されます。) |
![]() | GetService | Component またはその Container で提供されるサービスを表すオブジェクトを返します。 (Component から継承されます。) |
![]() | MemberwiseClone | オーバーロードされます。 ( MarshalByRefObject から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Disposed | コンポーネントの Disposed イベントを待機するイベント ハンドラを追加します。(Component から継承されます。) |
![]() | FileOk | ファイル ダイアログ ボックスの [開く] ボタンまたは [保存] ボタンをユーザーがクリックすると発生します。(FileDialog から継承されます。) |
![]() | HelpRequest | ユーザーがコモン ダイアログ ボックスの [?] ボタンをクリックすると発生します。(CommonDialog から継承されます。) |

Weblioに収録されているすべての辞書からOpenFileDialogを検索する場合は、下記のリンクをクリックしてください。

- OpenFileDialogのページへのリンク