Solved

Using a TreeView and images

Posted on 2000-04-26
20
403 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
  • 10
  • 7
  • 2
  • +1
20 Comments
 
LVL 22

Expert Comment

by:CJ_S
Comment Utility
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
Comment Utility
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
Comment Utility
could you show me the script you used when you got the string error?

CJ
0
 
LVL 1

Expert Comment

by:LorenG
Comment Utility
0
 
LVL 2

Author Comment

by:jrmcg
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
jrmcg@usa.net
0
 
LVL 1

Expert Comment

by:ASP_Ray
Comment Utility
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
Comment Utility
thanks
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 1

Accepted Solution

by:
ASP_Ray earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
What do you mean j.r.?  Are you having trouble loading images into Imagelist?
0
 
LVL 2

Author Comment

by:jrmcg
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
My pleasure j.r.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now