新建一个停靠窗口PaletteSet的Dock属性时,使用以下代码发现不生效:

    1. var ps = new Autodesk.AutoCAD.Windows.PaletteSet("test");
    2. ps.Size = new System.Drawing.Size(150, 300);
    3. ps.Dock = Autodesk.AutoCAD.Windows.DockSides.Left;
    4. System.Windows.Forms.UserControl myCtrl = new SidebarForm();
    5. ps.Add("subtest", myCtrl);
    6. ps.Visible = true;

    经过搜索得知,设置Dock属性前,必须设置Visible属性为true,否则Dock属性不生效,正确代码如下:

    1. var ps = new Autodesk.AutoCAD.Windows.PaletteSet("test");
    2. ps.Size = new System.Drawing.Size(150, 300);
    3. ps.Visible = true;
    4. ps.Dock = Autodesk.AutoCAD.Windows.DockSides.Left;
    5. System.Windows.Forms.UserControl myCtrl = new SidebarForm();
    6. ps.Add("subtest", myCtrl);

    原文链接:https://blog.csdn.net/andr0id/article/details/121746791