database treeview

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi everyone!

i'm searching for a tutorial or an example for how to fill a treeview with
information from my ms sql database. i've found some on "code project" and
other sites, but nothing like a real tutorial for beginners.
does anyone knows some helpflul links or can give me a short intro? my
treeview should act like a navigator or explorer-like, so that a click on a
node shows some detailed information on the right side of my win app.

i'm using VS 2005 beta and SQL server 2005 beta ... thx!

Mike
 
Hi,

well it depends on how easy it is for me to understand your code ;)
but i would appreciate if you mail it to (e-mail address removed).

thank you so far!

Mike
 
Mike,

In my opinion is almost the only way you can do this by going through the
datarows of your main datatable in an indexed for loop and add the nodes to
the treeview accoording to that.

If it is about a related data in your dataset than it has to be along with
the childrelations of a datarow that you are adding which has than its own
for index loop for the child nodes, and that going on as deep as your
relations are.

In my opinion is this quiet simple.

Don't forget to set the handlers after that you have populated the treeview
and not before.

I hope this helps,

Cor
 
Hi,
I wrote an application that stores the tree hierarchy of directories to
database. It can than read that information from database table and populate
it back in a tree view. You can save any number of trees in the table. If I
email it to u, will that be helpful? I have it at home and I can email it
tomorrow.

Ab.
http://joehacker.blogspot.com
 
If you are willing to have a look at a commercial solution then you
might want to consider Infralution's Virtual Tree. This provides a
very flexible data binding mechanism that allows you bind directly to
data from ADO.NET dataset. Unlike other attempts at tree databinding
it does not force you to put all your data in one table - so you can
use it for real world applications. One of the sample projects
illustrates binding to the Microsoft Northwind sample database (eg
Customers->Orders->Details).

You can find more information and download a fully functional
evaluation version at:
www.infralution.com/virtualtree.html

Regards
Grant Frisken
Infralution
 
Hi,
about the sample I sent u: (The code is all in vs2k5 beta 2, if you want to
run in 2k3, than all you'll have to do is copy and past the right code)
I burn a lot of cds of my personal data and the things that I download from
net. But I used to lost track of whats on what cd. If I need the file1 than
what cd is it on? So I wrote this application to help me keep track of where
my data is. If I need something I simply search for it through this
application and it tells me what cd has that file.

Its simple to use. Once you make sure that the app is connecting fine with
the db. You select New CD from File menu. On the new form you locate the
folder whose contents you wanna save to db. It can be any folder, I always
locate my cd drive and click ok. Now from Options menu you select "Read CD".
All contents of the folder are displayed in the treeview. Once you see and
confirm all the data, type the CD Name that you want the tree data to be
known with in the textbox, than you can click "Save Data" and your data will
be saved to db. Once the mouse starts responding you can close the Form.

The CDs are loaded at the form startup in the main form. You can also
refresh Cds with File->Refresh CDs. As soon as you select any cd from the
drop down, its contents will be displayed in the tree.

I dont know how good r u at recursion, but mostly all the code uses
recursion due to the nature of the work.

Main functions are :
- popcd() : populates cds in the combo
- cmbcds_SelectedIndexChanged : populates the tree with the contents of the
selected cd.

in newcd.cs form:
- saverecursivedata : for saving tree contents to the db.

Since you were concerned about how easy my code will be to understand. I
cant guarantee but I can suggest that you start simple, ie, just create a
very simple directory tree structure on your hardrive, not more than three
nested folders and see the code executing through stepping-in inside the
debugger. First observe the the data being saved and the watch how the data
gets populated in the tree view.

Ask any questions that you may have.

(I have sent u the db script for the db as well. And ignore the imagelist
indexes code, its not working anyway)

Ab.
http://joehacker.blogspot.com
 
Back
Top