<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Accessing AcCustomize MultiSelectTreeview in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/accessing-accustomize-multiselecttreeview/m-p/9564481#M19435</link>
    <description>&lt;P&gt;I have never thought of using this control from AcCustomize.dll. Seeing your question, I went for a try and did not have the issue of yours, well, at least for my very&amp;nbsp; simplified code. Here is what I did:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Start an AutoCAD .NET add-in dll project.&lt;/P&gt;
&lt;P&gt;2. Add necessary AutoCAD .NET references, including acCustomize.dll, which also be configured as "Copy Local" to False.&lt;/P&gt;
&lt;P&gt;3. Add a Win Form.&lt;/P&gt;
&lt;P&gt;4. Since the controls in AcCustomize.dll cannot be added into VS Designer's Toolbox, the MultiSelectTreeview control is added to the win form by code - adding it to form in the form's constructor and populating it in Form_Load event handler, as shown below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;    public partial class Form1 : Form
    {
        private Autodesk.AutoCAD.Customization.MultiSelectTreeview _treeview = null;
        private TreeNode _rootNode = null;

        public Form1()
        {
            InitializeComponent();

            _treeview = new Autodesk.AutoCAD.Customization.MultiSelectTreeview();
            _treeview.Dock = DockStyle.Fill;
            _treeview.CheckBoxes = true;
            Controls.Add(_treeview);
        }

        private void PopulateTreeview()
        {
            _rootNode = new TreeNode("ROOT");

            AddChildren(_rootNode, "First Level");

            foreach (TreeNode node in _rootNode.Nodes)
            {
                AddChildren(node, "Second Level");
            }

            _treeview.Nodes.Add(_rootNode);
        }

        private void AddChildren(TreeNode node, string childName)
        {
            for (int i = 1; i &amp;lt;= 10; i++)
            {
                var text = childName + " " + i.ToString().PadLeft(2, '0');
                var nd = node.Nodes.Add(text);
            }   
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            PopulateTreeview();
        }
    }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;5. show the form with MultiSelectTreeview with following command:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;       [CommandMethod("MyForm")]
        public static void ShowFormWithTreeview()
        {
            using (var form = new Form1())
            {
                CadApp.ShowModalDialog(CadApp.MainWindow.Handle, form, false);
            }
        }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The modal form display the treeview correctly, which is no different from a regular Win form Treeview, except for each node having a default icon. I did not find a way to select multiple nodes, though (tried to hold either Ctrl, or Shift key while clicking nodes). See picture below:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="MultiSelectTreeview.png" style="width: 621px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/780703i5DBE7D837DF4C9DE/image-size/large?v=v2&amp;amp;px=999" role="button" title="MultiSelectTreeview.png" alt="MultiSelectTreeview.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, not sure where the error you have is from. I used Acad2021, VS2019, and target to .NET framework 4.8. But I do not see other later versions of AutoCAD/.NET framework would make it different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 06 Jun 2020 14:27:03 GMT</pubDate>
    <dc:creator>norman.yuan</dc:creator>
    <dc:date>2020-06-06T14:27:03Z</dc:date>
    <item>
      <title>Accessing AcCustomize MultiSelectTreeview</title>
      <link>https://forums.autodesk.com/t5/net-forum/accessing-accustomize-multiselecttreeview/m-p/9563081#M19434</link>
      <description>&lt;P&gt;I found the control I want for a form which is under AcCustomize, the MultiSelectTreeview.&amp;nbsp; I was getting errors though and it appeared to be mismatched version numbers.&lt;/P&gt;&lt;P&gt;So I installed the AutoCAD-2020-SDK and now the version numbers are the same.&lt;/P&gt;&lt;P&gt;However, the problem persists.&amp;nbsp; The error says it cannot find the assembly ‘accoremgd’ version 23.1.0.0 (the 2020 version).&amp;nbsp; However, checking the properties it is right there.&lt;/P&gt;&lt;P&gt;My goal is to have selectable multiple (preferred only two, but got to get to multiple first) nodes on the tree view.&amp;nbsp; In my case, I do want to control a little too which two.&amp;nbsp; In this case, multiple parent nodes that can have multiple child nodes.&amp;nbsp; I want to be able to select the parent and one child, or two children under the same parent.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I can control that if I can get to Multiple selections first.&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AcCustomize error pic.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/780384i4BF1C4AF0BDA9BD2/image-size/large?v=v2&amp;amp;px=999" role="button" title="AcCustomize error pic.png" alt="AcCustomize error pic.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2020 15:28:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/accessing-accustomize-multiselecttreeview/m-p/9563081#M19434</guid>
      <dc:creator>dennis</dc:creator>
      <dc:date>2020-06-05T15:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing AcCustomize MultiSelectTreeview</title>
      <link>https://forums.autodesk.com/t5/net-forum/accessing-accustomize-multiselecttreeview/m-p/9564481#M19435</link>
      <description>&lt;P&gt;I have never thought of using this control from AcCustomize.dll. Seeing your question, I went for a try and did not have the issue of yours, well, at least for my very&amp;nbsp; simplified code. Here is what I did:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Start an AutoCAD .NET add-in dll project.&lt;/P&gt;
&lt;P&gt;2. Add necessary AutoCAD .NET references, including acCustomize.dll, which also be configured as "Copy Local" to False.&lt;/P&gt;
&lt;P&gt;3. Add a Win Form.&lt;/P&gt;
&lt;P&gt;4. Since the controls in AcCustomize.dll cannot be added into VS Designer's Toolbox, the MultiSelectTreeview control is added to the win form by code - adding it to form in the form's constructor and populating it in Form_Load event handler, as shown below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;    public partial class Form1 : Form
    {
        private Autodesk.AutoCAD.Customization.MultiSelectTreeview _treeview = null;
        private TreeNode _rootNode = null;

        public Form1()
        {
            InitializeComponent();

            _treeview = new Autodesk.AutoCAD.Customization.MultiSelectTreeview();
            _treeview.Dock = DockStyle.Fill;
            _treeview.CheckBoxes = true;
            Controls.Add(_treeview);
        }

        private void PopulateTreeview()
        {
            _rootNode = new TreeNode("ROOT");

            AddChildren(_rootNode, "First Level");

            foreach (TreeNode node in _rootNode.Nodes)
            {
                AddChildren(node, "Second Level");
            }

            _treeview.Nodes.Add(_rootNode);
        }

        private void AddChildren(TreeNode node, string childName)
        {
            for (int i = 1; i &amp;lt;= 10; i++)
            {
                var text = childName + " " + i.ToString().PadLeft(2, '0');
                var nd = node.Nodes.Add(text);
            }   
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            PopulateTreeview();
        }
    }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;5. show the form with MultiSelectTreeview with following command:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;       [CommandMethod("MyForm")]
        public static void ShowFormWithTreeview()
        {
            using (var form = new Form1())
            {
                CadApp.ShowModalDialog(CadApp.MainWindow.Handle, form, false);
            }
        }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The modal form display the treeview correctly, which is no different from a regular Win form Treeview, except for each node having a default icon. I did not find a way to select multiple nodes, though (tried to hold either Ctrl, or Shift key while clicking nodes). See picture below:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="MultiSelectTreeview.png" style="width: 621px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/780703i5DBE7D837DF4C9DE/image-size/large?v=v2&amp;amp;px=999" role="button" title="MultiSelectTreeview.png" alt="MultiSelectTreeview.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, not sure where the error you have is from. I used Acad2021, VS2019, and target to .NET framework 4.8. But I do not see other later versions of AutoCAD/.NET framework would make it different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jun 2020 14:27:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/accessing-accustomize-multiselecttreeview/m-p/9564481#M19435</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2020-06-06T14:27:03Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing AcCustomize MultiSelectTreeview</title>
      <link>https://forums.autodesk.com/t5/net-forum/accessing-accustomize-multiselecttreeview/m-p/9566685#M19436</link>
      <description>&lt;P&gt;Thanks Norman.&amp;nbsp; Your way worked.&amp;nbsp; In my case, the control does show up in the VS Toolbox and I was trying to drag-drop it from there.&amp;nbsp; Don't ask "how did it show up", I don't know, it was just there and I was exploring it.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 11:56:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/accessing-accustomize-multiselecttreeview/m-p/9566685#M19436</guid>
      <dc:creator>dennis</dc:creator>
      <dc:date>2020-06-08T11:56:09Z</dc:date>
    </item>
  </channel>
</rss>

