TreeView.NodeMouseDoubleClick イベント
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
ユーザーがマウスで TreeNode をダブルクリックしたときに発生します。
public:
event System::Windows::Forms::TreeNodeMouseClickEventHandler ^ NodeMouseDoubleClick;
public event System.Windows.Forms.TreeNodeMouseClickEventHandler NodeMouseDoubleClick;
member this.NodeMouseDoubleClick : System.Windows.Forms.TreeNodeMouseClickEventHandler
Public Custom Event NodeMouseDoubleClick As TreeNodeMouseClickEventHandler
イベントの種類
例
次のコード例は、 NodeMouseDoubleClick イベントを処理する方法と、 TreeNodeMouseClickEventArgsを使用する方法を示しています。 この例を実行するには、treeView1 という名前の TreeView を含むWindows フォームにコードを貼り付けます。 サンプルが実行されているシステムのc:\ ディレクトリにあるファイルの名前をtreeView1に設定し、treeView1のNodeMouseDoubleClick イベントをこの例のtreeView1_NodeMouseDoubleClick メソッドに関連付けます。 この例では、この例を実行しているコンピューターに対する管理者特権がユーザーに付与されている必要があります。
// If a node is double-clicked, open the file indicated by the TreeNode.
private:
void InitialTreeView_NodeMouseDoubleClick(Object^ sender,
TreeNodeMouseClickEventArgs^ e)
{
try
{
// Look for a file extension.
if (e->Node->Text->Contains("."))
{
System::Diagnostics::Process::Start("c:\\" + e->Node->Text);
}
}
// If the file is not found, handle the exception and inform the user.
catch (System::ComponentModel::Win32Exception^)
{
MessageBox::Show("File not found.");
}
}
// If a node is double-clicked, open the file indicated by the TreeNode.
void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
{
try
{
// Look for a file extension.
if (e.Node.Text.Contains("."))
System.Diagnostics.Process.Start(@"c:\" + e.Node.Text);
}
// If the file is not found, handle the exception and inform the user.
catch (System.ComponentModel.Win32Exception)
{
MessageBox.Show("File not found.");
}
}
' If a node is double-clicked, open the file indicated by the TreeNode.
Sub treeView1_NodeMouseDoubleClick(ByVal sender As Object, _
ByVal e As TreeNodeMouseClickEventArgs) _
Handles treeView1.NodeMouseDoubleClick
Try
' Look for a file extension, and open the file.
If e.Node.Text.Contains(".") Then
System.Diagnostics.Process.Start("c:\" + e.Node.Text)
End If
' If the file is not found, handle the exception and inform the user.
Catch
MessageBox.Show("File not found.")
End Try
End Sub
注釈
このイベントは、ノードが折りたたまれているか展開されているかを示すプラス記号 (+) またはマイナス記号 (-) を含む、ユーザーがマウスでツリー ノードの任意の部分をダブルクリックしたときに発生します。
イベントの処理の詳細については、「処理とイベントの発生」を参照してください。