C#控件TreeView在选中后图标改变的解决办法

C#控件TreeView选中图标的解决办法

         '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:

intmyCurrentImageIndex=0;
TreeNodenode=myTreeView.Nodes.Add("new node!");
node.ImageIndex=node.SelectedImageIndex=myCurrentImageIndex;

         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.

intmyNewImageIndex=1;

node.ImageIndex=node.SelectedImageIndex=myNewImageIndex;

转载于:https://www.cnblogs.com/hewei2012/archive/2013/05/27/3102246.html

已标记关键词 清除标记
表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
相关推荐
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页