Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is TreeView.Nodes[int].Name in C#?

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?

like image 830
Cole Tobin Avatar asked Dec 11 '25 12:12

Cole Tobin


1 Answers

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
like image 153
Mark Hall Avatar answered Dec 14 '25 00:12

Mark Hall



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!