• 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;

  • 相关阅读:
    第22课对象的销毁
    第21课对象的构造顺序
    第20课 初始化列表的使用
    第19课构造函数(下)
    第18课构造函数(中)
    第17课构造函数(上)
    第16课类的真正形态
    调试环境的搭建
    Hello,DTOS!(下)
    Hello,DTOS!(中)
  • 原文地址:https://www.cnblogs.com/hewei2012/p/3102246.html
Copyright © 2020-2023  润新知