Link to home
Start Free TrialLog in
Avatar of jrmcg
jrmcg

asked on

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.
Avatar of CJ_S
CJ_S
Flag of Netherlands image

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
Avatar of jrmcg
jrmcg

ASKER

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

CJ
Avatar of jrmcg

ASKER

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
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?
Avatar of jrmcg

ASKER

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.
Avatar of jrmcg

ASKER

jrmcg@usa.net
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?
Avatar of jrmcg

ASKER

thanks
ASKER CERTIFIED SOLUTION
Avatar of ASP_Ray
ASP_Ray
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jrmcg

ASKER

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.
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.
Avatar of jrmcg

ASKER

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.
What do you mean j.r.?  Are you having trouble loading images into Imagelist?
Avatar of jrmcg

ASKER

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...
Avatar of jrmcg

ASKER

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...
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.
Avatar of jrmcg

ASKER

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.
My pleasure j.r.