Solved

treeview with richtextbox

Posted on 2004-09-27
10
572 Views
Last Modified: 2012-06-27
i have a treeview with ten nodes

two rich text boxes    notes   and   newwork


want to click on a node and write text in notes from node1.txt , node2.txt, etc for that specific node

then enter text in newwork for that node

then save the whole thing so all work will be there next time and can be edited and expanded
0
Comment
Question by:aijohn
  • 4
  • 2
10 Comments
 
LVL 18

Expert Comment

by:armoghan
ID: 12166662
Make an Class which has two Variables notes and  newwork of String type, attach this Object with the tag object of the nodes, On Focus of any node, populate the strings in the RichTextBoxes by picking the values from Tag object.

Now how to save a Tree you can see the following example
http://www.dotnetspider.com/Technology/KBPages/544.aspx
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12166669
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12166675
better examples for saving TreeView
http://www.thecodeproject.com/cs/miscctrl/loadandsave.asp
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:aijohn
ID: 12176317
nice examples, but I'm trying to get a specific answer on how to fill textboxes with input from text file
depending on which node is selected
0
 
LVL 4

Expert Comment

by:eozz_2000
ID: 12176551
Please, I am so slow...

When you select a Node, you want to view its contents in a richTextBox?
0
 

Author Comment

by:aijohn
ID: 12176602
I want to view textfile1.txt when node1 selected
textfile2.txt when node2 selected, etc,, etc
in first text box


then i want to input new text for each node in the second textbox on same form

and then save the whole thing
0
 
LVL 18

Accepted Solution

by:
armoghan earned 500 total points
ID: 12176707
This is how you can load a file line by line.

Dim file_name As String = DataFile()
        Dim stream_reader As New IO.StreamReader(file_name)
        Dim line As String

        ' Read the file one line at a time.
        line = stream_reader.ReadLine()
        Do While Not (line Is Nothing)
            ' Trim and make sure the line isn't blank.
            line = line.Trim()
            If line.Length > 0 Then _
                lstAnimals.Items.Add(line)

            ' Get the next line.
            line = stream_reader.ReadLine()
        Loop
        lstAnimals.SelectedIndex = 0
        stream_reader.Close()
/////////////////////////////


and this is how you determine which node is clicked by attaching a listener to the TreeView and finding the node on click

Private Sub TreeView1_MouseDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) Handles
TreeView1.MouseDown

Dim Node As System.Windows.Forms.TreeNode

If e.Button = MouseButtons.Left Then
Node = TreeView1.GetNodeAt(New System.Drawing.Point(e.X, e.Y))
If Not Node Is Nothing Then Debug.WriteLine(Node.Text)
End If

End Sub

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question