zoukankan      html  css  js  c++  java
  • TreeView 循环遍历选中的value

    代码
      private void GetAllNodeText()
        {
            
    foreach (TreeNode tn in _treeView1.Nodes)
            {
                
    if (tn.Checked == false)
                {
                    
    if (string.IsNullOrEmpty(_operCode))
                    {
                        _operCode 
    += tn.Value;
                    }
                    
    else
                    {
                        _operCode 
    += "," + tn.Value;
                    }

                }
                
    if (tn.ChildNodes.Count > 0)
                {
                    
    foreach (TreeNode tn1 in tn.ChildNodes)
                    {
                        
    if (tn1.Checked == false)
                        {
                            
    if (string.IsNullOrEmpty(_operCode))
                            {
                                _operCode 
    += tn1.Value;
                            }
                            
    else
                            {
                                _operCode 
    += "," + tn1.Value;
                            }
                        }

                    }
                }

            }
        }
     
     
     _operCode 就是接收的选中的值 
     
     
    2------------------将值赋给Treeview  
    代码
     foreach (TreeNode tn in _treeView1.Nodes)
                            {
                                
    for (int j = 0; j < strurl.Length; j++)
                                {
                                    
    if (tn.Value == strurl[j])
                                    {
                                        tn.Checked 
    = false;
                                    }
                                    
    foreach (TreeNode tn1 in tn.ChildNodes)
                                    {
                                        
    if (tn1.Value == strurl[j])
                                        {
                                            tn1.Checked 
    = false;
                                        }
                                    }
                                }
                            }
     
    //我存储的是规律的是  不选中的值存储在数据库 所以在我取出数据的时候 我先让我的Treeview 全部选中 然后将与数据库等同的值不选中 所以我tn.Checked = false;
     
  • 相关阅读:
    NSIndexPath 延伸
    iOS进阶推荐的书目
    配置App真机测试证书的流程 一览
    NSAttributedString 的21种属性 详解
    KVO & 通知 小记
    贝塞尔曲线 & CAShapeLayer & Stroke 动画 浅谈
    提升开发人员修为的探讨
    热门IOS 第三方库
    drawRect & 内存 -> 深究
    CALayer & UIView 关系浅析
  • 原文地址:https://www.cnblogs.com/wanglinglong/p/1691778.html
Copyright © 2011-2022 走看看