?
Solved

Saving a treeview's structure

Posted on 1998-08-21
4
Medium Priority
?
212 Views
Last Modified: 2010-04-30
Hello I have a treeview on a form.  This treeview control is created by the user to show the structure of a specific system.  What I need is a way to save the structure of the treeview control between session.  I'm really not sure how to go about this so if anyone has any idea on how to create this structure in a database.

If you can give me full source on how to do this.  Basically I'm looking for two function SaveSystem and LoadSystem.  If you provide these function I'll triple the points.
 
0
Comment
Question by:PCav
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1430332
How complicated the tree  control is:
1. Is there a need in saving image info
2. How many levels
3. Is it text only, or also keys
4. How big it in general
0
 

Author Comment

by:PCav
ID: 1430333
Question one image info needed.

Question two realistically 3 or 4 levels, but could possible be larger.

It needs to save text, plus 2 other pieces of information (one is in the tag of the node and the other depends on the type of icon the person used (there are only less than 10 icons that won't ever change)

General size less than 100 entries all together in most cases, but again could be larger.
0
 
LVL 6

Accepted Solution

by:
anthonyc earned 150 total points
ID: 1430334
Assuming that the imagelist has all the icons you need in it, then you can do this.. by saving to the registry (this can be adjusted to save to an INI file, which I think is better)

public sub SaveTreeview(tvw as treeview)
  dim nodCur as node
  dim szVal  as string

  for each nodCur in tvw.nodes
     savesetting app.exename, tvw.name & "_Node" & nodcur.index & "_Key", nodcur.key
     savesetting app.exename, tvw.name & "_Node" & nodCur.index & "_Text", nodCur.text
     SaveSetting app.exename, tvw.name & "_Node" & nodcur.index & "_Icon", nodCur.image
     SaveSetting app.exename, tvw.name & "_Node" & nodcur.index & "_Index" & nodCur.index

     if not nodcur.parent is nothing then
        savesetting app.exename, tvw.name & "_Node" & nodcur.index & "_Parent" & iif(nodcur.key = "", nodcur.index, nodcur.key)
     end if
  next nodcur
end sub

public sub LoadTreeview(tvw as treeview)
  dim nodCur as node
  dim nIndex as integer
  dim szVal  as string
  dim szkey  as string
  dim szIcon as string
  dim szPar  as string

  tvw.nodes.clear

  nIndex = getsetting(app.exename, tvw.name & "_Node1_Index", 0)
  do until nIndex = 0
    szKey = getsetting(app.exename, tvw.name & "_Node" & nIndex & "_Key", "")
    szVal = getsetting(app.exename, tvw.name & "_Node" & nIndex & "_Text", "")
    szIcon = getsetting(app.exename, tvw.name & "_Node" & nIndex & "_Icon", "")
    szPar = getsetting(app.exename, tvw.name & "_Node" & nIndex & "_Parent", "")

    if len(szPar) > 0 then
      set nodCur = tvw.nodes.add(iif(isNumeric(szPar), clng(szPar), szPar), tvwchild, szkey, szval, szicon, szicon)
    else
      set nodCur = tvw.nodes.add(,, szkey, szval, szicon, szicon)
    end if

    nIndex = getsetting(app.exename, tvw.name & "_Node" & (nIndex + 1) & "_Index", 0)
  loop
end sub
0
 

Author Comment

by:PCav
ID: 1430335
Thank You for your help I don't think I'm gonna use your code.  I gonna save the Treeview control in and XML document.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month13 days, 21 hours left to enroll

801 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