Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP!! I need to create a treeview manually!!

Status
Not open for further replies.

crleacock

Vendor
Nov 29, 2001
33
US
I sure hope someone can help me because I'm really in a fix! I just started playing with Visual Studio 2005 about a week ago and at the time didn't know a thing about code. But I got saddled with this project so I need to deliver by Monday!

We've got a lot of PDFs on a network drive that people need access to. The requirements are a good looking interface where they can browse categories ala Windows Explorer treeview (just the left side preferably) and then click a file name and have it open up the PDF. Here's where I run into problems.

Another requirement is to be able to search the test in all PDFs at once, so I created an index. Well, Adobe indexes aren't searchable in a web browser so I can't just create a simple web page. Also, I can't change everyone's PC so the docs open up in Reader and not IE. That left me with creating something in VS2005 so I can still have the treeview.

I've tried various things but if I automatically populate the tree I get all the folders and files I don't want to see. Changing the structure of the directories isn't an option either.

When I manually add nodes to the treeview it looks exactly the way I want but I don't know how to click on one of the files and have it open up.

Does anyone have any suggestions at all??? Is there a way to manually add nodes and then specify a link to the file? If I could do that, what code would be needed to open it? HEEEELLLLLLP!!!!!

Thank you, and goodnight. :)
 
well the treeview has a nodes collection so you can add whatever you like to that.

dim t as new treenode("blah")
treeviwe1.nodes.add(t)

pput that in a do while loop and voila.

then the treeview has a selectednode property who tells you wich one is selected.

and then you have something called proccess, I think you can find it in system.io, wich will open the file with the program that's associated to it.

Best of luck. Wich monday was that?


Christiaan Baes
Belgium

"My new site" - Me
 
I'm not sure if tree nodes have both a text and value properties, but if not, you could create a new class and inherit it from treenode, then add the value property. That way you could specify the title in the text property and the file path in the value.

As for the index, you could >try< (long shot) pulling the text out of each PDF and storing it in a database, then when the user wants to search all document, you just hit the database instead. Pulling the text out of a LOT of pdf's will either take a lot of time, or some handy coding/components.

If you store all of the info in a database you could do it in 2 tables.

Category:
Category_PK (Integer Primary Key)
Parent_FK (refers to the parent category so you can have nested groups)
Title

Documents:
Document_PK (Integer Primary Key)
Category_FK (Foreign key links to the category)
FileName (Full path and file name)
Title (Title to display in the tree node)
DocumentText (The text from the PDF)

Just some ideas.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
As for the index, you could >try< (long shot) pulling the text out of each PDF and storing it in a database, then when the user wants to search all document, you just hit the database instead. Pulling the text out of a LOT of pdf's will either take a lot of time, or some handy coding/components.

I think that is something indexing services is doing.

Christiaan Baes
Belgium

"My new site" - Me
 
I'm not familiar with any PDF indexing services, and in my experience Adobe's search functionality is about slow as tar. If there is a good indexing solution out there, I'd love to hear about it!

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Well, I think I've gotten it figured out. I put the file path in the node's "Tag" field and then used that to open the file. Here's the code:

private void treeView1_DblClick(object sender, System.EventArgs e)
{
// Cast the sender to a TreeView and get the tag of the first selected item.
System.Windows.Forms.TreeView tw = (System.Windows.Forms.TreeView)sender;
string filename = tw.SelectedNode.Tag.ToString();

if (tw.SelectedNode.ImageIndex != 0)
{
try
{
// Attempt to run the file
System.Diagnostics.Process myProc = new System.Diagnostics.Process();
myProc.EnableRaisingEvents = false;
myProc.StartInfo = new System.Diagnostics.ProcessStartInfo(filename);
myProc.Start();
}
catch(Exception x)
{
MessageBox.Show(x.Message);
}
}
}

Now if I could just make the treeview background transparent... :)
 
yeah i see but this is the vb.net forum, oh well, six of one, half-dozen of the other.
 
Well, when I posted I had tried and failed in C# so was trying it with VB. Then I found info on C# so went back to it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top