Where is TreeView.Nodes[int].Name in C#?
-
04-06-2021 - |
Domanda
I'm working on a VB.NET to C# conversion and I'm currently stuck with a TreeView
object.
Dim Arguments1 As String = path & "\" & fs & " ls " & TreeView1.Nodes(ccc).Name
So far, I can only get to this:
string Arguments1 = path + "\\" + fs + " ls " + ?
IN VB.NET, TreeView
has a method, Nodes(int)
, which I can get the Name
property from. However, C# doesn't have a Nodes(int)
method. I think it might be TreeView1.Items[ccc]
, but TreeView1.Items[ccc].Name
doesn't compile because the object Items[int]
returns doesn't contains a Name
property. How do I get it?
Soluzione
It seems like you are translating code written for a WinForms TreeView
that has a Nodes
property with code for a WPF TreeView
which has an Items
property. You need to cast the returned value to a TreeViewItem
to get the Name
property. Your C# code will then be:
string Arguments1 = path + "\\" + fs + " ls " + ((TreeViewItem)TreeView1.Items[ccc]).Name
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow