c# - How to identify the name of selected TreeNode whether a namespace or a class? -


i making windows forms application. using treeview display namespaces.

        var namespaces = assembly.gettypes()             .tolookup(ns => ns.namespace);           foreach (var subnamespace in namespaces)         {             treenode assemblynode = multiselectmethodtree.nodes                                              .add(subnamespace.key);                         } 

since there huge number of methods , classes in project, thought of displaying classes when user clicks expand('+') namespace, , display methods when class expanded.

    private void multiselectmethodtree_afterexpand(object sender, treevieweventargs e)     {         treenode expandednode = e.node;     } 

in afterexpand event, not able identify whether namespace or class.

you inherit treenode class create specific types each namespace, class, enum etc.

example:

public class namespacetreenode : treenode { /* may add suited properties. */ } 

and instead of creating treenode object, create object of these types.

to identify node selected, can following:

private void multiselectmethodtree_afterexpand(object sender, treevieweventargs e) {     treenode expandednode = e.node;      if(expandednode namespacetreenode) { /* todo */ } } 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -