CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1

    Avoiding the display of an image on treeview node

    Hello,

    i work under the following environment: WinXP, CSharpDevelop under .NET 2.0.

    Problem description:
    To simplify it, I'm trying to make a single node on a treeView. The treeview is linked to an imageList which contains some images. I wanted to show the treeview node without images. It seems not to be working in design time and in runtime.

    The code is as follow:
    Code:
    node = new TreeNode(strValue); 
    node.Tag = "BTN" + intNextNode.ToString()+";0;;"; 
    tV.Nodes.Add(node); 
    node.ImageIndex = -2; 
    node.SelectedImageIndex = -2; 
    
    The result is always the same, it shows the first item of the imageList when nothing is selected and no image when the node is selected.

    How do i do to have this node without images?

    Thx for your patience.
    David Domingues at webrickco@gmail.com. Feel free to visit http://www.webrickco.com

  2. #2
    Join Date
    Mar 2006
    Location
    Craiova, Romania
    Posts
    439

    Re: Avoiding the display of an image on treeview node

    Hmm ... it seems that an underflow value isn't working , it will always choose the first picture in the image collection . Try instead an overflow index .
    Code:
    node.ImageIndex = 200; 
    node.SelectedImageIndex = 200;
    where I supposed you don't have 200 pictures in the collection
    Bogdan

    If someone helped you then please Rate his post and mark the thread as Resolved
    Please improve your messages appearance by using tags [ code] Place your code here [ /code]

  3. #3

    Re: Avoiding the display of an image on treeview node

    I used an underflow value because it is how it was generate in the *.Designer.cs when i add a node manually, giving the 2 proprieties, ImageIndex and SelectedImageIndex, the value of "(NONE)".
    In this case, the image displayed was the first image added to the imageList object.

    With your suggestion, the node displays the last image added to the imageList object.

    Maybe i should load a transparent gif as first image...
    I just thought there was a way...

    Thx for your suggestion!
    David Domingues at webrickco@gmail.com. Feel free to visit http://www.webrickco.com

  4. #4

    Re: Avoiding the display of an image on treeview node

    Not completly satisfactory, but adding a transparent picture to the imageList previous to all other images solves the problems.
    David Domingues at webrickco@gmail.com. Feel free to visit http://www.webrickco.com

  5. #5
    Join Date
    Mar 2006
    Location
    Craiova, Romania
    Posts
    439

    Re: Avoiding the display of an image on treeview node

    I used the overflow value and worked on my machine
    Bogdan

    If someone helped you then please Rate his post and mark the thread as Resolved
    Please improve your messages appearance by using tags [ code] Place your code here [ /code]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured