Solved

Using a TreeView and images

Posted on 2000-04-26
20
407 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Load data upon clicking a button 8 48
Asp in server side with Mssql Server 7 4 33
Adjust an existing ASP Query 45 25
ASP Classic, check if Querystring is UCase or LCase 8 28
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…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

735 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