tdcntt

Could you please tell me how to change the icon when the 'plus/minus' sign in a treeview control is changed. For example, if the sign beside a node is "-", then display icon "A"; otherwise, display icon "B".

I would highly appreciate your help!



Re: Visual Basic Language Change icon in treeview control

Jay Vora

Private Sub Form_Load()
Dim imgX As ListImage
' Add images to ListImages collection.
Set imgX = ImageList1. _
ListImages.Add(,"rocket",LoadPicture("icons\industry\rocket.ico"))
Set imgX = ImageList1. _
ListImages.Add(,"jet",LoadPicture("icons\industry\plane.ico"))
Set imgX = ImageList1. _
ListImages.Add(,"car",LoadPicture("icons\industry\cars.ico"))

ListView1.Icons = ImageList1 ' Set Icons property.

' Add Item objects to the ListView control.
Dim itmX As ListItem
Set itmX = ListView1.ListItems.Add()
' Reference by index.
itmX.Icon = 1
itmX.Text = "Rocket" ' Set Text string.
Set itmX = ListView1.ListItems.Add()
' Reference by key ("jet").
itmX.Icon = "jet"
itmX.Text = "Jet" ' Set Text string.
Set itmX = ListView1.ListItems.Add()
itmX.Icon = "car"
itmX.Text = "Car" ' Set Text string.
End Sub
try this for treeview logic can b used ..





Re: Visual Basic Language Change icon in treeview control

Jay Vora

refer to http://p2p.wrox.com/topic.asp TOPIC_ID=35294

also http://www.obout.com/t2/ex_changeicons.aspx much better ..

http://forum.java.sun.com/thread.jspa threadID=5133180&messageID=9481080 in java ..

dear frnd if u find this helpful mark it as helpful n as answer as well.. thx..






Re: Visual Basic Language Change icon in treeview control

tdcntt

Hi Jay Vora,

Thank you very much for your response! I am sorry that I forgot to mention the language. I am using C#. I am pretty new to C# and I don't know VB at all. I was wondering if you had a similar example for C#. Thanks again!!!





Re: Visual Basic Language Change icon in treeview control

DMan1

tdcntt wrote:

Hi Jay Vora,

Thank you very much for your response! I am sorry that I forgot to mention the language. I am using C#. I am pretty new to C# and I don't know VB at all. I was wondering if you had a similar example for C#. Thanks again!!!

Hello tdcntt,

If you would like C# replies you should post your question in the c# forum...this is the Visual Basic Forum






Re: Visual Basic Language Change icon in treeview control

tdcntt

Thanks Dman1 for reminding me and thanks Jay Vora again for trying to help me!



Re: Visual Basic Language Change icon in treeview control

Jay Vora

no problem dear frnd..forum is for queries so dnt fear to post any comment..

and ya if u find any of my post helpful like the ans of ur post plz mark it as helpful or as an answer or both ..thx