Using a TreeView and images

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.
LVL 2
jrmcgAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
ASP_RayConnect With a Mentor Commented:
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
 
CJ_SCommented:
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
 
jrmcgAuthor Commented:
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
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
CJ_SCommented:
could you show me the script you used when you got the string error?

CJ
0
 
jrmcgAuthor Commented:
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
 
ASP_RayCommented:
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
 
jrmcgAuthor Commented:
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
 
jrmcgAuthor Commented:
jrmcg@usa.net
0
 
ASP_RayCommented:
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
 
jrmcgAuthor Commented:
thanks
0
 
jrmcgAuthor Commented:
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
 
ASP_RayCommented:
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
 
jrmcgAuthor Commented:
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
 
ASP_RayCommented:
What do you mean j.r.?  Are you having trouble loading images into Imagelist?
0
 
jrmcgAuthor Commented:
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
 
jrmcgAuthor Commented:
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
 
ASP_RayCommented:
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
 
jrmcgAuthor Commented:
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
 
ASP_RayCommented:
My pleasure j.r.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.