Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Problem in setting icon to TreeView Control

Problem in setting icon to TreeView Control

Scheduled Pinned Locked Moved C#
help
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    freshonlineMax
    wrote on last edited by
    #1

    Hello Friends From 2 days ago i'm trying to show icons for treeview nodes programmatically. but i was failed. I have an ImageList with 2 16*16 icons. I have a TreeView Control too. I'm writing codes like below and I can see nodes, But i can't see any icon, I searched so many references in WebPages,but they confused me. treeView1.ImageList = imageList1; for (int i = 0; i < 4; ++i) { TreeNode n = new TreeNode("Node with image " + i.ToString()); n.ImageIndex = 0; n.SelectedImageIndex = 1; treeView1.Nodes.Add(n); } Please help me. Thank You. -- modified at 5:12 Sunday 30th April, 2006

    T S 2 Replies Last reply
    0
    • F freshonlineMax

      Hello Friends From 2 days ago i'm trying to show icons for treeview nodes programmatically. but i was failed. I have an ImageList with 2 16*16 icons. I have a TreeView Control too. I'm writing codes like below and I can see nodes, But i can't see any icon, I searched so many references in WebPages,but they confused me. treeView1.ImageList = imageList1; for (int i = 0; i < 4; ++i) { TreeNode n = new TreeNode("Node with image " + i.ToString()); n.ImageIndex = 0; n.SelectedImageIndex = 1; treeView1.Nodes.Add(n); } Please help me. Thank You. -- modified at 5:12 Sunday 30th April, 2006

      T Offline
      T Offline
      tarasn
      wrote on last edited by
      #2

      I checked your code .You must fix the line number 4 from n.SelectedImageIndex = 4; to n.SelectedImageIndex = 1; because your image list has only two images and the treeview can't display image for selected node DevIntelligence.com - My blog for .Net Developers

      F 1 Reply Last reply
      0
      • T tarasn

        I checked your code .You must fix the line number 4 from n.SelectedImageIndex = 4; to n.SelectedImageIndex = 1; because your image list has only two images and the treeview can't display image for selected node DevIntelligence.com - My blog for .Net Developers

        F Offline
        F Offline
        freshonlineMax
        wrote on last edited by
        #3

        Hello again Ok, I saw that and that was not the main problem, beacause i just typed wrong imageindex here and in my project it was correct. Thank you for your advice.

        R 1 Reply Last reply
        0
        • F freshonlineMax

          Hello again Ok, I saw that and that was not the main problem, beacause i just typed wrong imageindex here and in my project it was correct. Thank you for your advice.

          R Offline
          R Offline
          Ravi Bhavnani
          wrote on last edited by
          #4

          Perhaps you've forgotten to set the Treeview's ImageList property? /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

          1 Reply Last reply
          0
          • F freshonlineMax

            Hello Friends From 2 days ago i'm trying to show icons for treeview nodes programmatically. but i was failed. I have an ImageList with 2 16*16 icons. I have a TreeView Control too. I'm writing codes like below and I can see nodes, But i can't see any icon, I searched so many references in WebPages,but they confused me. treeView1.ImageList = imageList1; for (int i = 0; i < 4; ++i) { TreeNode n = new TreeNode("Node with image " + i.ToString()); n.ImageIndex = 0; n.SelectedImageIndex = 1; treeView1.Nodes.Add(n); } Please help me. Thank You. -- modified at 5:12 Sunday 30th April, 2006

            S Offline
            S Offline
            S Senthil Kumar
            wrote on last edited by
            #5

            Does imageList1 actually contain the images? Does setting the property using the Forms Editor work? Regards Senthil _____________________________ My Blog | My Articles | My Flickr | WinMacro

            F 1 Reply Last reply
            0
            • S S Senthil Kumar

              Does imageList1 actually contain the images? Does setting the property using the Forms Editor work? Regards Senthil _____________________________ My Blog | My Articles | My Flickr | WinMacro

              F Offline
              F Offline
              freshonlineMax
              wrote on last edited by
              #6

              Hello Everything is Ok, I have imagelist with icons (*.png,*.ico) and i set imagelist property of TreeView control. I have no problem in wizard mode. It means when i add and set nodes and icons from properties window there is no problem. Problem accures in programmatically mode. I think i have problem with pictures size or type, Can yo help me ?

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups