如何使用字符串传递值而不是从c#中的树节点中选择

时间:2014-08-20 09:58:45

标签: c# treeview categories

我有一棵树:

//Create and populate an instance of category tree
        int catId = Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings["processesCategoryId"]);
        Category cat = new Category(catId);
        CategoryUITree.categorySet2UITree(cat.name,
            PSProcesses, this.categoryTreeView, true, false);

当用户选择节点时,它将通过以下方式检测:

CategorySet processes = CategoryUITree.UITree2CategorySet(this.categoryTreeView, false);

因此,如果我选择一个名为“Design”的节点,使用debug我可以看到进程的值为{Design}。 现在,我想直接传递值“Design”来处理,从字符串变量,不需要从树中选择。 我试过了:

CategorySet processes = "Design"

但它显示错误类型的错误。 无论如何我可以使用字符串值来形成CategorySet进程吗? CategorySet由以下内容定义:

public class CategorySet : IList, ICollection, IEnumerable
{
    protected ArrayList _categorySet;
    protected int _setId;

    public CategorySet();
    public CategorySet(int id);

    public int Count { get; }
    public int id { get; }
    public bool IsFixedSize { get; }
    public bool IsReadOnly { get; }
    public bool IsSynchronized { get; }
    public object SyncRoot { get; }

    public Category this[int index] { get; }

    public int Add(Category categoryToAdd);
    public void Add(CategorySet catSet);
    public void Add(int categoryID);
    public void Add(string phraseSet);
    public void Clear();
    protected void constructFromReader(IDataReader rdr);
    public bool Contains(Category categoryToFind);
    public bool Contains(int catId);
    public void CopyTo(Category[] array, int index);
    public void Delete();
    public void Delete(SqlTransaction transaction);
    public object GetAt(int index);
    public string GetCategoryList();
    public IEnumerator GetEnumerator();
    public int IndexOf(Category categoryToFind);
    public void Insert(int index, Category categoryToInsert);
    public CategorySet Intersect(CategorySet withThis);
    public void Remove(Category categoryToRemove);
    public void Remove(int id);
    public void Remove(string name);
    public void RemoveAll();
    public void RemoveAt(int index);
    public void Save();
    public void Save(SqlTransaction transaction);
    public CategorySet Subtract(CategorySet set2);
    public string ToIdString(string separator);
    public string ToNameString(string separator);
    public override string ToString();
    public CategorySet Union(CategorySet withThis);

    protected class SortCategoryById : IComparer
    {
        public SortCategoryById();
    }

    protected class SortCategoryByName : IComparer
    {
        public SortCategoryByName();
    }
}

0 个答案:

没有答案