473,395 Members | 1,554 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

After days and hours, could not achieve to do this ...

Hello MVPs and other Gurus,

I (urgently) need to fill a TreeView in a Windows form with the
data of a text file structured as under :

- begin
Root\
Root\Node1\
Root\Node1\SubNode11\
Root\Node1\SubNode11\SubNode111\
Root\Node1\SubNode11\SubNode112\
Root\Node1\SubNode12\
Root\Node1\SubNode12\SubNode121\
Root\Node1\SubNode12\SubNode122\
Root\Node1\SubNode12\SubNode123\
Root\Node1\SubNode13\
Root\Node1\SubNode14\
Root\Node2\
Root\Node2\SubNode21\
Root\Node2\SubNode21\SubNode211\
Root\Node2\SubNode21\SubNode211\SubNode2111\
Root\Node2\SubNode21\SubNode211\SubNode2111\SubNod e2112\
Root\Node2\SubNode21\SubNode211\SubNode2111\SubNod e2112\SubNode21121
Root\Node2\SubNode21\SubNode212\
Root\Node2\SubNode21\SubNode213\
Root\Node3\
- end

Any name in this example is fake and can be replaced
with a whatever string matching the structure.

I easily extracted each Node.Text from the file, but after days
and hours roaming around the availabilities of VB.Net (Visual Studio 2003)
and various Internet Sites, I could not achieve to fill the TreeView properly.
;-(

Any tip, link, code, advice, and support will be highly appreciated.

TIA to all.
Patrick Penet
:-)

PS: sorry for crossposting in the VB.Net and Visual Studio related NGs
but it's a matter of time now.
--
Remove the dot to answer in my box
ph******@club-internet.fr
====================
Nov 20 '05 #1
8 872
Patrick Penet wrote:
Hello MVPs and other Gurus,

I (urgently) need to fill a TreeView in a Windows form with the
data of a text file structured as under :

- begin
Root\
Root\Node1\
Root\Node1\SubNode11\
Root\Node1\SubNode11\SubNode111\
Root\Node1\SubNode11\SubNode112\ [snip]
PS: sorry for crossposting in the VB.Net and Visual Studio related NGs
but it's a matter of time now.


I think you need a better problem description.
It probably makes excellent sense to to someone working with the same
set of tools you use. We have a saying of "not being able to see
forest for the trees". I, as an "and other", can not see past the
"leaves". ( bad pun, very bad pun ;)

Nov 20 '05 #2
Cor
Hi Patrick,

I am not a MVP and I am feeling me no guru.
But maybe you can use this?

It is not exactly as you told it.

\\\
For i As Integer = 1 To 9
Dim tn As New TreeNode("Root\Node" & i.ToString & "\")
TreeView1.Nodes.Add(tn)
Dim sn As New TreeNode
For j As Integer = 1 To 5
sn = tn.Nodes.Add("Root\Node" & i.ToString & "\SubNode\" & _
i.ToString & j.ToString)
Dim sn2 As New TreeNode
For h As Integer = 1 To 5
sn2 = sn.Nodes.Add("Root\Node" & i.ToString & "\SubNode\" & _
i.ToString & j.ToString & "\" _
& "SubNode" & i.ToString & j.ToString & h.ToString)
Next
Next
Next
///
I hope this helps?

Cor
Nov 20 '05 #3
Hi,

In addition to this piece off code, read your text-file line by line and use
the " Split" function.

It's just an idea.....

Robert
"Cor" <no*@non.com> wrote in message
news:OM****************@tk2msftngp13.phx.gbl...
Hi Patrick,

I am not a MVP and I am feeling me no guru.
But maybe you can use this?

It is not exactly as you told it.

\\\
For i As Integer = 1 To 9
Dim tn As New TreeNode("Root\Node" & i.ToString & "\")
TreeView1.Nodes.Add(tn)
Dim sn As New TreeNode
For j As Integer = 1 To 5
sn = tn.Nodes.Add("Root\Node" & i.ToString & "\SubNode\" & _
i.ToString & j.ToString)
Dim sn2 As New TreeNode
For h As Integer = 1 To 5
sn2 = sn.Nodes.Add("Root\Node" & i.ToString & "\SubNode\" & _ i.ToString & j.ToString & "\" _
& "SubNode" & i.ToString & j.ToString & h.ToString)
Next
Next
Next
///
I hope this helps?

Cor

Nov 20 '05 #4
Hi Cor,

Thank your for answering, but the code that you
proposed will produce a "regular" TreeView, I mean
that each TreeNodes would have the same number of
subNodes etc., which is not my aim (the values of i, j and h
are not predictible line by line, as shown in example).

As I explained, I could extract each node name with the Split
function, but I cannot figure out how to produce the code that
would add the node at the right place one by one.

It might be, I guess, some recursive sub that would loop
to itself until the branch is completed, but again how ?

Root\
Root\Node1\
Root\Node1\SubNode11\
Root\Node1\SubNode11\SubNode111\
- up to here, it's easy because regular -

Root\Node1\SubNode11\SubNode112\
Root\Node1\SubNode12\
- there, I'm getting problems, I am unable to add SubNode112
to SubNode11 nodes collection, idem for any next nodes regarding
the length of the branch -

I tried building collections, and then add them to the TreeView :
Coll1(Node1, Node2, Node3)
Coll2(SubNode11, SubNode12, SubNode13, SubNode14, SubNode21)
etc.
It's not working either, because Node3 do not have any subnode and
Node2 have 5 levels of subnodes, for example.
This is the point.
;-(((

Sorry for being so boring, but I am really facing this since days.

Thank you.
Patrick
"Cor" <no*@non.com> a écrit dans le message de news:OM****************@tk2msftngp13.phx.gbl...
Hi Patrick,

I am not a MVP and I am feeling me no guru.
But maybe you can use this?

It is not exactly as you told it.

\\\
For i As Integer = 1 To 9
Dim tn As New TreeNode("Root\Node" & i.ToString & "\")
TreeView1.Nodes.Add(tn)
Dim sn As New TreeNode
For j As Integer = 1 To 5
sn = tn.Nodes.Add("Root\Node" & i.ToString & "\SubNode\" & _
i.ToString & j.ToString)
Dim sn2 As New TreeNode
For h As Integer = 1 To 5
sn2 = sn.Nodes.Add("Root\Node" & i.ToString & "\SubNode\" & _
i.ToString & j.ToString & "\" _
& "SubNode" & i.ToString & j.ToString & h.ToString)
Next
Next
Next
///
I hope this helps?

Cor

Nov 20 '05 #5
Hi Richard,
Sorry for being unclear, please see my answer to Cor
it might be clearer.
Patrick

"Richard Owlett" <ro*****@atlascomm.net> a écrit dans le message de news:10*************@corp.supernews.com...
Patrick Penet wrote:
Hello MVPs and other Gurus,

I (urgently) need to fill a TreeView in a Windows form with the
data of a text file structured as under :

- begin
Root\
Root\Node1\
Root\Node1\SubNode11\
Root\Node1\SubNode11\SubNode111\
Root\Node1\SubNode11\SubNode112\

[snip]

PS: sorry for crossposting in the VB.Net and Visual Studio related NGs
but it's a matter of time now.


I think you need a better problem description.
It probably makes excellent sense to to someone working with the same
set of tools you use. We have a saying of "not being able to see
forest for the trees". I, as an "and other", can not see past the
"leaves". ( bad pun, very bad pun ;)

Nov 20 '05 #6
Hello Robert,

I did use the split function to extract the node names. The
problem is how to deal with them. Please see my answer to
Cor.

Best regards.
Patrick
Nov 20 '05 #7
Cor
Hi Patrick,
Thank your for answering, but the code that you
proposed will produce a "regular" TreeView, I mean
that each TreeNodes would have the same number of
subNodes etc., which is not my aim (the values of i, j and h
are not predictible line by line, as shown in example).

No it is not.

Just a little bit of own adding will do something, but here I did it
completly for you, although that I did not count exactly all the nodes.

You have to add of course your own texts, this is an example.

I hope this helps?

Cor

Dim l As Integer() = {0, 0, 1, 0, 1, 5}
Dim t As New TreeNode("Root")
TreeView1.Nodes.Add(t)
For i As Integer = 1 To 5
Dim tn As New TreeNode
tn = t.Nodes.Add("Root\Node" & i.ToString & "\")
Dim sn As New TreeNode
For j As Integer = 1 To l(i)
sn = tn.Nodes.Add("Root\Node" & i.ToString & "\SubNode\"
& _
i.ToString & j.ToString)
Dim sn2 As New TreeNode
For h As Integer = 1 To l(6 - j)
sn2 = sn.Nodes.Add("Root\Node" & i.ToString &
"\SubNode\" & _
i.ToString & j.ToString & "\" _
& "SubNode" & i.ToString & j.ToString & h.ToString)
Next
Next
Next

Nov 20 '05 #8
Many thanks, Cor, this will help me a lot ...
once I clearly understand the logic behind
and how I can adapt it to my needs.
:-)))

Thanks again and cheers.
Patrick
"Cor" <no*@non.com> a écrit dans le message de news:uS****************@tk2msftngp13.phx.gbl...
Hi Patrick,
Thank your for answering, but the code that you
proposed will produce a "regular" TreeView, I mean
that each TreeNodes would have the same number of
subNodes etc., which is not my aim (the values of i, j and h
are not predictible line by line, as shown in example).

No it is not.

Just a little bit of own adding will do something, but here I did it
completly for you, although that I did not count exactly all the nodes.

You have to add of course your own texts, this is an example.

I hope this helps?

Cor

Dim l As Integer() = {0, 0, 1, 0, 1, 5}
Dim t As New TreeNode("Root")
TreeView1.Nodes.Add(t)
For i As Integer = 1 To 5
Dim tn As New TreeNode
tn = t.Nodes.Add("Root\Node" & i.ToString & "\")
Dim sn As New TreeNode
For j As Integer = 1 To l(i)
sn = tn.Nodes.Add("Root\Node" & i.ToString & "\SubNode\"
& _
i.ToString & j.ToString)
Dim sn2 As New TreeNode
For h As Integer = 1 To l(6 - j)
sn2 = sn.Nodes.Add("Root\Node" & i.ToString &
"\SubNode\" & _
i.ToString & j.ToString & "\" _
& "SubNode" & i.ToString & j.ToString & h.ToString)
Next
Next
Next

Nov 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: JL | last post by:
To All, I have a SQL2KSP3a database(<1GB) running on a 4x3GB physical CPU with 4GB of ram. It is Windows Server 2003 with hyper-threading turn on. There are ~420 .Net users/cxns (fat client, no...
8
by: Michael | last post by:
I have this script that works the way I want except for one thing... Once it hits zero it starts to count up and looks like this: -1:0-1:0-1:0-18 with the last number counting up. Can anyone...
7
by: Stu | last post by:
Is there a simple function call within "C" that I can use to convert number of seconds (keep in mind this may be a type longlong and has to work on UNIX and NT) into Days, months, Hours, Minutes...
2
by: J M | last post by:
I rebooted a network device just few minutes ago and getting device-up-time value 3191. How do I convert a time elapsed in days hours minutes and seconds for above value? Example: This device...
19
by: Ricardo Perez Lopez | last post by:
Hello everyone: I'm a PostgreSQL newbie, working now with dates, times, timestamps and intervals. I have three questions about the above: FIRST: --------
1
by: baneaic | last post by:
I'm trying to create a form that will allow a user to enter certain job specifications (# of pages and # of copies) and then have a field that will automatically calculate how long that job will...
4
realin
by: realin | last post by:
hi guys.. I have made a function which counts the numbers of days or hours or minutes from the current datetime to the give datetime.. but i am confused while displaying number of days along with...
0
by: ravitunk | last post by:
hi all...i have a web service with a timer which has an Elapsed time of 1second(code should get executed for every second).....with the following code.....its running perfectly for the first time and...
5
by: zxo102 | last post by:
Hello All, I have a system. An instrument attched to 'com1' is wireless connected to many sensors at different locations. The instrument can forward the "commands" (from pyserial's write()) to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.