简体   繁体   中英

Get an Object from a TreeView node in C#

I'm writing an AutoCAD Plug-in that shows all the entities as Nodes in a TreeView. I want to be able to get the object from the Node to be able to work with programmatically. This is my code for when a node is clicked:

private void treeView1_MouseClick(object sender, MouseEventArgs e)
    {
        TreeNode node = treeView1.SelectedNode;
        propertyGrid1.SelectedObject = node;
        /*Entity selectedEntity = node.getObject() as Entity; Pseudo-code, need to know how to do this*/
    }

TreeNode具有Tag属性,旨在允许您将对象与Node关联。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM