<?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: How to close a PaletteSet from code in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-close-a-paletteset-from-code/m-p/3715498#M54375</link>
    <description>&lt;P&gt;Help!&lt;/P&gt;&lt;P&gt;How can I get a PaletteSet which is not created by myself?&lt;/P&gt;&lt;P&gt;e.g. now I know the way to get the ribbon paletteset by&amp;nbsp;Autodesk.AutoCAD.Ribbon.RibbonServices.RibbonPaletteSet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But how can I get other paletteset like this palette(or this is not a palette but a panel??):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/43728i55D47FD212FF1E7E/image-size/original?v=mpbl-1&amp;amp;px=-1" title="PaletteSet.png" alt="PaletteSet.png" align="center" border="0" /&gt;("Task pane" in English?)&lt;/P&gt;&lt;P&gt;Is there a property to get &amp;nbsp;all the palette collection??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 29 Nov 2012 08:54:28 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-11-29T08:54:28Z</dc:date>
    <item>
      <title>How to close a PaletteSet from code</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-close-a-paletteset-from-code/m-p/3548650#M54373</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Because there is no way to tell the difference between miniminise ("-") to close ("x") on paletteset. I put a button on my user control to write my own code to close the PaletteSet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;m_ps is the current PaletteSet, m_uc is my user control which has been loaded into m_ps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what code I need to write inside my close button click event to unload m_uc , close m_ps and set both m_uc and m_ps to nothing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Thanks very much&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jul 2012 16:35:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-close-a-paletteset-from-code/m-p/3548650#M54373</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-07-23T16:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to close a PaletteSet from code</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-close-a-paletteset-from-code/m-p/3553842#M54374</link>
      <description>&lt;P&gt;Hi Yaqi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Simply set the Visible property of the palette&amp;nbsp;to true/false from the button handler.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2012 14:08:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-close-a-paletteset-from-code/m-p/3553842#M54374</guid>
      <dc:creator>Balaji_Ram</dc:creator>
      <dc:date>2012-07-26T14:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to close a PaletteSet from code</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-close-a-paletteset-from-code/m-p/3715498#M54375</link>
      <description>&lt;P&gt;Help!&lt;/P&gt;&lt;P&gt;How can I get a PaletteSet which is not created by myself?&lt;/P&gt;&lt;P&gt;e.g. now I know the way to get the ribbon paletteset by&amp;nbsp;Autodesk.AutoCAD.Ribbon.RibbonServices.RibbonPaletteSet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But how can I get other paletteset like this palette(or this is not a palette but a panel??):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/43728i55D47FD212FF1E7E/image-size/original?v=mpbl-1&amp;amp;px=-1" title="PaletteSet.png" alt="PaletteSet.png" align="center" border="0" /&gt;("Task pane" in English?)&lt;/P&gt;&lt;P&gt;Is there a property to get &amp;nbsp;all the palette collection??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2012 08:54:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-close-a-paletteset-from-code/m-p/3715498#M54375</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-11-29T08:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to close a PaletteSet from code</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-close-a-paletteset-from-code/m-p/3725978#M54376</link>
      <description>&lt;P&gt;Sorry, I dont find any way to get access to the PaletteSet that hasnt been created by you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am just curious to know, why you would need that if it wasnt created by your plugin ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2012 16:44:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-close-a-paletteset-from-code/m-p/3725978#M54376</guid>
      <dc:creator>Balaji_Ram</dc:creator>
      <dc:date>2012-12-06T16:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to close a PaletteSet from code</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-close-a-paletteset-from-code/m-p/3726372#M54377</link>
      <description>&lt;P&gt;There is nowhere to get a PaletteSet which is not created by yourself, because AutoCAD does not save it to the application settings.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What we see on AutoCAD is &lt;STRONG&gt;ToolPalette&lt;/STRONG&gt;, which is different which PaletteSet. ToolPalette is stored as an external .ATC file that is controlled (read &amp;amp; save) by &lt;STRONG&gt;ToolPaletteManager.Manager&lt;/STRONG&gt; which can load external catalogs (content location URLs) to display on this ToolPalette. I don't see .NET API to load an existing ToolPalette from an external ATC file. From there you can handle it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PaletteSet is the code container that we can place our user controls (PaletteSet.Add method), and we have a right to handle it. But it is initialized by code and not saved to an external file like .ATC of ToolPalette.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Khoa&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2012 20:03:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-close-a-paletteset-from-code/m-p/3726372#M54377</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-12-06T20:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to close a PaletteSet from code</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-close-a-paletteset-from-code/m-p/3727272#M54378</link>
      <description>&lt;P&gt;You don't have access to PaletteSets that AutoCAD creates and uses (except for the Ribbon), but most of them have commands to close them (for example, "PROPERTIESCLOSE" will close the PropertiesPalette).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2012 12:38:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-close-a-paletteset-from-code/m-p/3727272#M54378</guid>
      <dc:creator>DiningPhilosopher</dc:creator>
      <dc:date>2012-12-07T12:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to close a PaletteSet from code</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-close-a-paletteset-from-code/m-p/13128572#M54379</link>
      <description>&lt;P&gt;12 years late. But hey, might be useful to someone.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The simplest way to close your palette is to simply execute the command that launched it, by using&amp;nbsp;SendStringToExecute() from the active document. Then handle the close in the command that launches the palette.&lt;BR /&gt;&lt;BR /&gt;So from your palette viewmodel, you can link up a button to close like so.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ceethreedeecom_0-1730722458093.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1429336i1EBDD4666370135D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ceethreedeecom_0-1730722458093.png" alt="ceethreedeecom_0-1730722458093.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This function would be in your viewmodel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public void ClosePalette(string commandName)
{
    Document doc = Application.DocumentManager.MdiActiveDocument;
    Editor ed = doc.Editor;
    try
    {
        if (doc != null)
        {
            doc.SendStringToExecute(commandName + "\n", true, false, false);
        }
    }
    catch (System.Exception ex)
    {
        ed.WriteMessage("Error closing palette: " + ex.Message);
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then in the command that launches your palette, you add a bit of toggle code. If the palette is already open then close it.. Like below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;static PaletteSet MyPalette ;
[CommandMethod("CTD", "CTD_MYCOMMANDNAME", CommandFlags.Modal)]
public void CTD_MYCOMMANDNAME()
{
    //Check if palette is open if not open it
    if (MyPalette == null)
    {
        MyPalette = new MyPaletteSet
        {
            Size = new Size(800, 500),
            Name = "My Palette Name",
            Visible = true
        };

    }
    else
    {
        //if the palette is open close it
        if (MyPalette.Visible)
        {
            MyPalette.Visible = false;
            MyPalette.Dispose();
        }
        else
        {
            //if the palette is closed open it
            MyPalette = new MyPaletteSet
            {
                Size = new Size(800, 500),
                Name = "My Palette Name",
                Visible = true
            };
            MyPalette.Visible = true;
        }
    }


}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Nov 2024 12:22:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-close-a-paletteset-from-code/m-p/13128572#M54379</guid>
      <dc:creator>ceethreedee.com</dc:creator>
      <dc:date>2024-11-04T12:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to close a PaletteSet from code</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-close-a-paletteset-from-code/m-p/13128898#M54380</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1114364"&gt;@ceethreedee.com&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While your code can close(actually hide) the PaletteSet from the hosted palette (WinForm/WPF usercontrol), it unnecessarily add a dependency to an outside factor (commandmethod name, which could be changed for some reasons, and code compiling would not catch the change, thus a potential bug breaking the execution).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A better approach would be to build the explicit ownership relation between the palette and the paletteset by ALWAY derive the custom PaletteSet from PaletteSet class: when adding usercontrol as Palette, set its owner/parent to the PalletteSet, so the palette would have access to the PaletteSet, this be able to close/hide it. Some pseudo code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;public class MyPalleteSet : PaletteSet&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; private UserControlA _palletteA;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; public MyPaletteSet(...):base(...)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _paletteA=new palleteA(this);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Add("xxxx", _paletteA);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; }&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;public class UserControlA : UserControl&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; private MyPaletteSet _parent = null;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; // Default constructor, required by VS desiner&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;public UserControlA()&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; InitializeComponents();&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;// constructor used when added to PaletteSet&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;public UserControlA(MyPaletteSet ps) : this()&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;_parent = ps;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;public void ClosePaletteSet()&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; _parent.Close();&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;}&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course, another way is to let usercontrol/palette raise an event (when a button of the usercontrol is clicked, for example). Then when the usercontrol is added to the PaletteSet, the PaletteSet registers an event handler, in which the PaletteSet can decide to close/hide itself, or even veto the closing request, if necessary.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Either way, once the custom PaletteSet is created, its palette child can call its Close() method from inside, no dependency to outside.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Nov 2024 14:52:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-close-a-paletteset-from-code/m-p/13128898#M54380</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2024-11-04T14:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to close a PaletteSet from code</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-close-a-paletteset-from-code/m-p/13133498#M54381</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan&lt;/a&gt;&amp;nbsp;have you attempted the pseudo code?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I recall having an issue handing the paletteset to the user control or a viewmodel. It doesn't shut it down when calling the Close() method. The palette just says visible on the screen without the user been able to do anything..&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2024 12:06:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-close-a-paletteset-from-code/m-p/13133498#M54381</guid>
      <dc:creator>ceethreedee.com</dc:creator>
      <dc:date>2024-11-06T12:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to close a PaletteSet from code</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-close-a-paletteset-from-code/m-p/13133665#M54382</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1114364"&gt;@ceethreedee.com&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PaletteSet.Close() actually hides itself, which is equivelant to set its Visibility property to Visibility.Hide. That is, once a PaletteSet is loaded, it stays in the AutoCAD's memory until AutoCAD session ends. That is why PaletteSet is usually instantiated as static instance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2024 13:42:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-close-a-paletteset-from-code/m-p/13133665#M54382</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2024-11-06T13:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to close a PaletteSet from code</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-close-a-paletteset-from-code/m-p/13133784#M54383</link>
      <description>&lt;P&gt;mmm just tried it..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Close() method doesn't work.. It just freezes the palette and doesn't remove it from the screen. Which is what i remember happening.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However setting the visibility property to false hides the palette. though. Odd...&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;            if (paletteSet != null)
            {
                paletteSet.Visible = false;
                //paletteSet.Close();
            }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2024 14:24:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-close-a-paletteset-from-code/m-p/13133784#M54383</guid>
      <dc:creator>ceethreedee.com</dc:creator>
      <dc:date>2024-11-06T14:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to close a PaletteSet from code</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-close-a-paletteset-from-code/m-p/13134179#M54384</link>
      <description>&lt;P&gt;Sorry, I should not use Close() method. In fact, in my coding history with PaletteSet, I never used Close(), which is inherited from Autodesk.AutoCAd.Windows.Window. I always used Visible property for true/false to show/hide the PaletteSet.&amp;nbsp; So, it is interesting that you prompted me that Close() method call would actually freeze the PaletteSet (while AutoCAD would still alive and even responsible). This behaviour is not limited when the Close() is called from a PaletteSet's child Palette.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway, as I suggested, it would be better to show/hide without having to know an external command name. For anyone who may read this thread, below is the simple code to show how to close/hide the PaletteSet from inside in 2 ways:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The UserControl as Palette&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;using System.Windows.Forms;

namespace MiscTest
{
    public partial class ThePalette : UserControl
    {
        private readonly PaletteSet _owner = null;

        public ThePalette()
        {
            InitializeComponent();
        }

        public ThePalette(PaletteSet owner) : this()
        {
            _owner = owner;
        }

        public event EventHandler ClosingRequested;

        private void btnClose_Click(object sender, EventArgs e)
        {
            if (_owner !=null)
            {
                MessageBox.Show("PaletteSet is to be closed directly from the child palette.");
                _owner.Visible=false;
            }
        }

        private void btnClosingEvent_Click(object sender, EventArgs e)
        {
            ClosingRequested?.Invoke(this, EventArgs.Empty);
        }
    }
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this is what the UserControl looks like:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="normanyuan_2-1730910964928.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1430538i27A3FFDB6FC8F449/image-size/medium?v=v2&amp;amp;px=400" role="button" title="normanyuan_2-1730910964928.png" alt="normanyuan_2-1730910964928.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The PaletteSet:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;using Autodesk.AutoCAD.Windows;
using System;
using System.Windows;

namespace MiscTest
{
    public class MyPaletteSet : PaletteSet
    {
        private readonly ThePalette _palette;
        public MyPaletteSet() : base("", "", new Guid("DDC2578B-1C9D-49EB-8B31-6A80520981E0"))
        {
            Dock = DockSides.None;
            Size = new System.Drawing.Size(400, 400);

            _palette = new ThePalette(this);
            Add("My Data View", _palette);
            _palette.ClosingRequested += (o, e) =&amp;gt;
            {
                MessageBox.Show("PaletteSet is to be closed by the request from child palette.");
                Visible=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 command to run:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;        private static MyPaletteSet _mypaletteSet = null;
        [CommandMethod("MyPS")]
        public static void ShowMyPaletteSet()
        {
            if (_mypaletteSet == null)
            {
                _mypaletteSet = new MyPaletteSet();
            }
            _mypaletteSet.Visible = true;
        }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As one can see, if using the raising "close request" event approach, the palette does not have to know anything about its owner/PaletteSet, which is a good coding practice. But in case that the child palette needs to access owner's power (properties/methods), simply pass the owner in a constructor would make things simple and straightforward. So, choose one of the 2 ways based on the needs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2024 16:36:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-close-a-paletteset-from-code/m-p/13134179#M54384</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2024-11-06T16:36:14Z</dc:date>
    </item>
  </channel>
</rss>

