TreeNodeMouseClickEventArgs.Node Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan simpul yang diklik.
public:
property System::Windows::Forms::TreeNode ^ Node { System::Windows::Forms::TreeNode ^ get(); };
public System.Windows.Forms.TreeNode Node { get; }
public System.Windows.Forms.TreeNode? Node { get; }
member this.Node : System.Windows.Forms.TreeNode
Public ReadOnly Property Node As TreeNode
Nilai Properti
Yang TreeNode diklik.
Contoh
Contoh kode berikut menunjukkan cara menangani NodeMouseDoubleClick peristiwa dan cara menggunakan TreeNodeMouseClickEventArgs. Untuk menjalankan contoh ini, tempelkan kode ke dalam Formulir Windows yang berisi bernama TreeViewtreeView1
. Isi treeView1
dengan nama file yang terletak di c:\
direktori sistem tempat sampel berjalan, dan kaitkan NodeMouseDoubleClick peristiwa treeView1
dengan treeView1_NodeMouseDoubleClick
metode dalam contoh ini.
// 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
Berlaku untuk
Saran dan Komentar
https://aka.ms/ContentUserFeedback.
Segera hadir: Sepanjang tahun 2024 kami akan menghentikan penggunaan GitHub Issues sebagai mekanisme umpan balik untuk konten dan menggantinya dengan sistem umpan balik baru. Untuk mengetahui informasi selengkapnya, lihat:Kirim dan lihat umpan balik untuk