locked
Using Error Provider with TreeView? RRS feed

  • Question

  • Can the standard error provider (icon) be used on Treeview nodes?

    I have one parent node with one child, I want to show the icon next to the parent only and remove the + and - images .

    Working with VB .NET, but can use a C# example. Thanks much! 

     

    Saturday, August 28, 2010 5:04 PM

Answers

  • Thanks for your reply.

    Ok, so here is what seems to work. I got the icon from here. I did a target save picture as... on the red provider icon.

    http://msdn.microsoft.com/en-us/library/a0d996e0.aspx

    Here is some sample code. I put the IC27018.gif in the resources folder.

     Dim TVNode As TreeNode
     TVNode = TreeView1.Nodes.Add("First Names")
     TVNode.Nodes.Add("Mike")
     TVNode.Nodes.Add("Bill")
     TVNode.Nodes.Add("John")
     TVNode.Nodes.Add("Pete")
    
     Dim myImageList As New ImageList()
     myImageList.Images.Add(My.Resources.IC27018)
     TreeView1.ImageList = myImageList
     TreeView1.ImageIndex = 0
     TreeView1.SelectedImageIndex = 0
     TreeView1.ExpandAll()
    

     

    • Marked as answer by msny Saturday, August 28, 2010 7:49 PM
    • Unmarked as answer by msny Saturday, August 28, 2010 7:53 PM
    • Marked as answer by msny Saturday, August 28, 2010 7:53 PM
    Saturday, August 28, 2010 7:46 PM

All replies

  • No, the TreeView does not support ErrorProvider on the individual TreeNodes.

    Consider some scheme where you change the image for the TreeNode yourself and provide a tooltip, etc. on the TreeNode with the error message.

     

    Saturday, August 28, 2010 5:59 PM
  • Thanks for your reply.

    Ok, so here is what seems to work. I got the icon from here. I did a target save picture as... on the red provider icon.

    http://msdn.microsoft.com/en-us/library/a0d996e0.aspx

    Here is some sample code. I put the IC27018.gif in the resources folder.

     Dim TVNode As TreeNode
     TVNode = TreeView1.Nodes.Add("First Names")
     TVNode.Nodes.Add("Mike")
     TVNode.Nodes.Add("Bill")
     TVNode.Nodes.Add("John")
     TVNode.Nodes.Add("Pete")
    
     Dim myImageList As New ImageList()
     myImageList.Images.Add(My.Resources.IC27018)
     TreeView1.ImageList = myImageList
     TreeView1.ImageIndex = 0
     TreeView1.SelectedImageIndex = 0
     TreeView1.ExpandAll()
    

     

    • Marked as answer by msny Saturday, August 28, 2010 7:49 PM
    • Unmarked as answer by msny Saturday, August 28, 2010 7:53 PM
    • Marked as answer by msny Saturday, August 28, 2010 7:53 PM
    Saturday, August 28, 2010 7:46 PM