从TreeNode而不是TreeNodeCollection进行索引

时间:2019-02-13 01:30:17

标签: c# treeview

在oreder中将图像设置为我的TreeView,我创建了一个接收TreeNodeCollection的方法,例如:

private void LoadDesignStatusNodeIcon(TreeNodeCollection tnc, int idx, int StatusKey, bool IsLocked)
        {
            // If the design is locked ignore Status Key and use folder locked
            if (IsLocked)
            {
                tnc[idx].ImageIndex = 12;
                tnc[idx].SelectedImageIndex = 12;
                return;
            }

            switch (StatusKey)
            {
                case 67:
                    tnc[idx].ImageIndex = 11;
                    tnc[idx].SelectedImageIndex = 11;
                    break;

                case 66: // folder locked
                    tnc[idx].ImageIndex = 12;
                    tnc[idx].SelectedImageIndex = 12;
                    break;

                case 65: // Folder Pending
                    tnc[idx].ImageIndex = 27;
                    tnc[idx].SelectedImageIndex = 27;
                    break;

                case 64: // hold (warning folder)
                    tnc[idx].ImageIndex = 25;
                    tnc[idx].SelectedImageIndex = 25;
                    break;

                default: // folder + folder edit
                    tnc[idx].ImageIndex = 20;
                    tnc[idx].SelectedImageIndex = 21;
                    break;
            }
        }

它可以正常工作,但现在我想发送简单的树节点而不是集合,所以我尝试相同的方法,但将TreeNode的TreeNodeCollection更改为:

   private void LoadNodeIcon(TreeNode tnc, int idx, int StatusKey, bool IsLocked)
      {
              ...code there
      }

但是我遇到了错误:

  

无法从“ System.Windows.Forms.TreeNode”转换为   'System.Windows.Forms.TreeNodeCollection'

是否不可能发送简单的TreeNode而不是集合?问候

0 个答案:

没有答案