PC Review


Reply
Thread Tools Rate Thread

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

 
 
Patrick Penet
Guest
Posts: n/a
 
      21st Feb 2004
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\SubNode2112\
Root\Node2\SubNode21\SubNode211\SubNode2111\SubNode2112\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
(E-Mail Removed)
====================


 
Reply With Quote
 
 
 
 
Richard Owlett
Guest
Posts: n/a
 
      21st Feb 2004
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



 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      21st Feb 2004
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


 
Reply With Quote
 
Robert
Guest
Posts: n/a
 
      21st Feb 2004
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" <(E-Mail Removed)> wrote in message
news:OMauV0J%(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Patrick Penet
Guest
Posts: n/a
 
      22nd Feb 2004
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" <(E-Mail Removed)> a écrit dans le message de news:OMauV0J%(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Patrick Penet
Guest
Posts: n/a
 
      22nd Feb 2004
Hi Richard,
Sorry for being unclear, please see my answer to Cor
it might be clearer.
Patrick

"Richard Owlett" <(E-Mail Removed)> a écrit dans le message de news:(E-Mail Removed)...
> 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
>
>
>



 
Reply With Quote
 
Patrick Penet
Guest
Posts: n/a
 
      22nd Feb 2004
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


 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      22nd Feb 2004
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



 
Reply With Quote
 
Patrick Penet
Guest
Posts: n/a
 
      23rd Feb 2004
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" <(E-Mail Removed)> a écrit dans le message de news:uSiMEqS%(E-Mail Removed)...
> 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
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula to convert Hours to Days, Hours Minutes jamilla General Software 1 21st May 2010 03:31 AM
Converting total number of hours (>24 hours) into days MV Rao Microsoft Excel Misc 1 24th Jan 2008 12:50 PM
Display Sum of hours as an equivalent in days and hours Yipeeee Microsoft Excel Misc 2 17th Dec 2007 02:03 PM
Problem converting Hours to Days, Hours, Minutes =?Utf-8?B?Wnl6eng=?= Microsoft Excel Worksheet Functions 4 24th Oct 2005 04:19 PM
converting hours to days,hours,minutes =?Utf-8?B?TF9uX2Rh?= Microsoft Excel Worksheet Functions 2 29th May 2005 06:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:37 AM.