'SelectedImageIndex's intent is to allow displaying a different image upon selection than what is set by the 'ImageIndex' for a particular node. To keep these two consistent it is necessary to set them to the same value. This can be done at design time or programmatically depending on your needs.

          For example, if the images never change then it is as simple as setting them concurrently when a new node is added to the TreeView:

TreeNodenode=myTreeView.Nodes.Add("new node!");

         However, if you do change the ImageIndex value for any reason after its initial creation (such as a response to some kind of user action), then you must also change the SelectedImageIndex as well. Otherwise, they will become inconsistent.



posted @ 2013-05-27 19:40  何卫  阅读(485)  评论(0编辑  收藏