469,950 Members | 2,061 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

TreeView

Let say i have a bunch of files. Logfiles that is stored in subfolders.
Folder1
--logfile1
--logfile2
--logfile3
Folder2
--logfile1
--logfile2

I want to display these files using data from the files in an TreeView
control. Like this:

Folder1
--DATE1
----logfile1
----logfile2
--DATE2
----logfile3
Folder2
--DATE1
----logfile1
----logfile2

In other words i want to be able to sort the logfiles in a treeview control
using Folder->DATE->logfile.

As i see it i need to generate an object that contains data about the file.
These objects should be stored in an array within another object that is the
date. Dateobject is in an array within folder object.

This question is maybee simular to an previous one that i have asked in this
forum, but i dont regard this as an repost. I'm a newbee trying to learn
this language :-)

SO if you have any code samples or can point me to some it would help me a
lot.

Best regards
Nov 16 '05 #1
2 4112

The TreeView control does not support databinding, a techinque used to
display and edit data already stored in some datastructure.
Since you can't use databinding, you can create whatever structure you want.
It would make sence to use a structure that is easy to map over to a
hierarchical structure.

Each TreeNode that is added to the TreeView has a Nodes collection that
contains the sub-nodes for the next level. The exercise then becomes to add
each node into the right place, this depends entirely on what you want to
achieve, have a look at the MSDN samples for an idea of how to do it.

Another option is to use the TreeView as the data structure. This is only
advisable if you have a small program and don't have to view the same data
in multiple ways. Each TreeNode has a Tag property you can use to keep the
reference to the actual file. This reference can then be used for TreeView
context menus etc.

You can use the FileInfo object to get information about a file.
Chris

"Trond Hoiberg" <th******@broadpark.no> wrote in message
news:41******@news.broadpark.no...
Let say i have a bunch of files. Logfiles that is stored in subfolders.
Folder1
--logfile1
--logfile2
--logfile3
Folder2
--logfile1
--logfile2

I want to display these files using data from the files in an TreeView
control. Like this:

Folder1
--DATE1
----logfile1
----logfile2
--DATE2
----logfile3
Folder2
--DATE1
----logfile1
----logfile2

In other words i want to be able to sort the logfiles in a treeview
control using Folder->DATE->logfile.

As i see it i need to generate an object that contains data about the
file. These objects should be stored in an array within another object
that is the date. Dateobject is in an array within folder object.

This question is maybee simular to an previous one that i have asked in
this forum, but i dont regard this as an repost. I'm a newbee trying to
learn this language :-)

SO if you have any code samples or can point me to some it would help me a
lot.

Best regards

Nov 16 '05 #2
Thank you. I can not use FileInfo because i want to display data from inside
the file. That is why i want to make a class that is picking out data from
the file. One of those fields is a date/time (logging started). That filed
is it i want to display in the treeView control.

Folder
--DateFromInsideFile
---Logfile

That is why i have som trouble with this :-)
Best regards
Trond
"Christopher Kimbell" <c_*******@online.nospam> wrote in message
news:OV**************@TK2MSFTNGP12.phx.gbl...

The TreeView control does not support databinding, a techinque used to
display and edit data already stored in some datastructure.
Since you can't use databinding, you can create whatever structure you
want. It would make sence to use a structure that is easy to map over to a
hierarchical structure.

Each TreeNode that is added to the TreeView has a Nodes collection that
contains the sub-nodes for the next level. The exercise then becomes to
add each node into the right place, this depends entirely on what you want
to achieve, have a look at the MSDN samples for an idea of how to do it.

Another option is to use the TreeView as the data structure. This is only
advisable if you have a small program and don't have to view the same data
in multiple ways. Each TreeNode has a Tag property you can use to keep the
reference to the actual file. This reference can then be used for TreeView
context menus etc.

You can use the FileInfo object to get information about a file.
Chris

"Trond Hoiberg" <th******@broadpark.no> wrote in message
news:41******@news.broadpark.no...
Let say i have a bunch of files. Logfiles that is stored in subfolders.
Folder1
--logfile1
--logfile2
--logfile3
Folder2
--logfile1
--logfile2

I want to display these files using data from the files in an TreeView
control. Like this:

Folder1
--DATE1
----logfile1
----logfile2
--DATE2
----logfile3
Folder2
--DATE1
----logfile1
----logfile2

In other words i want to be able to sort the logfiles in a treeview
control using Folder->DATE->logfile.

As i see it i need to generate an object that contains data about the
file. These objects should be stored in an array within another object
that is the date. Dateobject is in an array within folder object.

This question is maybee simular to an previous one that i have asked in
this forum, but i dont regard this as an repost. I'm a newbee trying to
learn this language :-)

SO if you have any code samples or can point me to some it would help me
a lot.

Best regards


Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

42 posts views Thread by lauren quantrell | last post: by
5 posts views Thread by SoKool | last post: by
1 post views Thread by paradox | last post: by
6 posts views Thread by L.M | last post: by
14 posts views Thread by Mr.D | last post: by
3 posts views Thread by christof | last post: by
1 post views Thread by kvicky | last post: by
8 posts views Thread by Matt MacDonald | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.