Solved

Using a TreeView and images

Posted on 2000-04-26
20
408 Views
Last Modified: 2012-08-13
I am having a problem attaching images to a treeview in ASP.

I initialize a treeview in the window_onload event.  I have included an imagelist but that does not work.  it gives me a "imagelist must be initialized before use" message.  I have tried to set the image properties at design time and at run-time.  Neither way seems to work.  If I try and set them at run-time, i get an error about the string(path) being invalid in the LoadPicture call in the Add method of the imagelist.  I know the path is valid.

I am offering 500 points for this and would like the code that will do it.  I don't want a link to a sample or anything.

Thank-you in advance.

J.R.
0
Comment
Question by:jrmcg
[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
  • 10
  • 7
  • 2
  • +1
20 Comments
 
LVL 22

Expert Comment

by:CJ_S
ID: 2751436
Since we don't know your code we cannot know how far you are at the moment and how your treeview is built up.

CJ
0
 
LVL 2

Author Comment

by:jrmcg
ID: 2751480
Here is the code I use to load the tree.
the image list is just an image list object inserted onto the page.  I have tried right clicking and setting properties and setting them at run time.



sub LoadTVW

    Dim rs
    Dim nodX
    Dim MainKey
    Dim CatID
   
    Set rs = m_oObj.GetMainCategoryList()
    If Not rs.EOF Then
        rs.Sort = "CategoryName"
    End If
    Do Until rs.EOF
        MainKey = "Cat" & CStr(rs.fields("CategoryID"))
        CatID = rs.fields("CategoryID")
        set nodX = tvwDrugCat.Nodes.Add(, , MainKey, Trim(rs.fields("CategoryName")))
        nodX.Tag = CatID
        rs.MoveNext
    Loop
   
    Set rs = Nothing
    Set nodX = Nothing
   
end sub
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 2751560
could you show me the script you used when you got the string error?

CJ
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 1

Expert Comment

by:LorenG
ID: 2751569
0
 
LVL 2

Author Comment

by:jrmcg
ID: 2751799
I see from the link above that the LoadPicture doesn't work - so the question becomes how do I insert those image objects?

sub window_onload
      
      dim imgx
      
      set m_oObj = CreateGMTObject("GMTRx.IDrugs")
      set imgx = ImageList1.ListImages.Add( ,"CAT",LoadPicture("\pharmacy.gif"))
      set imgx = ImageList1.ListImages.Add( ,"DRG",LoadPicture("\drugs.bmp"))
      set tvwDrugCat.ImageList = ImageList1
      LoadTVW

end sub
0
 
LVL 1

Expert Comment

by:ASP_Ray
ID: 2753516
I have a complete demo of the Treeview and Imagelist controls implementing licensing and downloading of the controls when needed.  The question is how do I get it to you and still claim the points (which I sorely need), I am new to Experts-Exchange.  Zipping the files and emailing them to you is an option but would I still be able to claim the points?
0
 
LVL 2

Author Comment

by:jrmcg
ID: 2753551
as long as it will work in asp you can have the points i will give you the points.  You can just post the comment above as an answer.
0
 
LVL 2

Author Comment

by:jrmcg
ID: 2753552
jrmcg@usa.net
0
 
LVL 1

Expert Comment

by:ASP_Ray
ID: 2753563
Ok, within half-an-hour I'll email it to you.  My computer is acting up so I'll have to restart it.

It will contain a file called ReadMe.htm with the explanation.  I'll also post a comment here on how to put it together if I think it is necessary.

You'll hear from me soon, ok?
0
 
LVL 2

Author Comment

by:jrmcg
ID: 2753567
thanks
0
 
LVL 1

Accepted Solution

by:
ASP_Ray earned 500 total points
ID: 2753685
I have emailed you a demo of the Microsoft VB 5 Treeview control using Imagelist for it's icons.  The demo demonstrates how to properly set up licensing of the controls, how to properly set up downloading of the controls when needed, and brings to your attention a bug in the Imagelist control which prevents you from using it unless you know how to circumvent the bug.  Let me know if you have nay problems with it.
0
 
LVL 2

Author Comment

by:jrmcg
ID: 2753723
It looks like that is what i might need.  Do you know how to generate that DATA property to hold my images as opposed to microsofts basic stuff?

thanks

j.r.
0
 
LVL 1

Expert Comment

by:ASP_Ray
ID: 2753902
No jrmcg, I never looked into that.  I had enough trouble with the basic stuff so I just stuck with that once I got it working.
0
 
LVL 2

Author Comment

by:jrmcg
ID: 2753908
It was worth a shot.
I appreciate your help with this.  The points are yours.  I have tested your code and it works the way I need it to.  I will continue to try and find a way to get my own images in there.  You don't happen to have a list or know the key names for all of the images in the microsoft supplied stuff do you.  If you could e-mail me the list or anything that might help so that i will know what icons are available to me I would appreciate it.

Thanks again,

J.R.
0
 
LVL 1

Expert Comment

by:ASP_Ray
ID: 2753918
What do you mean j.r.?  Are you having trouble loading images into Imagelist?
0
 
LVL 2

Author Comment

by:jrmcg
ID: 2753923
Yes - i didn't see where images were actually getting loaded into the list.
Did I miss it?
I will look again but i didn't think i saw where i could load my own...

thanks...
0
 
LVL 2

Author Comment

by:jrmcg
ID: 2753925
Yes - i didn't see where images were actually getting loaded into the list.
Did I miss it?
I will look again but i didn't think i saw where i could load my own...

thanks...
0
 
LVL 1

Expert Comment

by:ASP_Ray
ID: 2753956
The Imagelist control that I sent is preloaded with a number of images.  You can delete and load your images as you like.  You do this by going into design mode in Visual Interdev 6.0, right clicking the Imagelist control (the one which looks like a set of 3 mailing envelopes), selecting properties from the pop-up menu,and selecting the Images tab.  You will then see all the images loaded and be able to delete and reload images.  JUST REMEMBER, NEVER MAKE THE CONTROL EMPTY OF ALL IMAGES.
0
 
LVL 2

Author Comment

by:jrmcg
ID: 2753974
I was just so used to it not working I figured it had to be coded into the data property or something.  Thank-you very much that did the trick.

J.R.
0
 
LVL 1

Expert Comment

by:ASP_Ray
ID: 2753984
My pleasure j.r.
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

751 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