用户控件的行为类似于标准窗口,仅局限于一个窗格

发布于 2024-11-18 01:54:55 字数 361 浏览 5 评论 0原文

我正在编写一个程序来为我生成代码,并且由于界面非常简单,我正在根据 Game Maker 设计 UI。它有一个 SplitContainer,Panel1 包含 TreeView,Panel2 包含任意数量的独立窗口(真正的窗口,而不是一些黑客的解决方法)。我想使用用户控件来存储用于修改内容的控件,但我无法找到任何方法将其放入 splitContainer 的 Panel2 内的窗口中。有人可以帮助我吗?

这是一个很好的例子:

https://i.sstatic.net/CG6kO.png

这两个精灵财产窗口是我正在尝试做的事情。

I'm making a program to generate code for me, and I'm fashioning the UI after Game Maker due to how easy the interface is. It has a SplitContainer with Panel1 containing a TreeView and Panel2 containing an arbitrary amount of self-contained windows (real windows, not some hacky workaround). I wanted to use user-controls to store the controls I use to modify things, but I can't figure out any way to put it in a window inside the splitContainer's Panel2. Can anyone help me?

Here's a good example:

https://i.sstatic.net/CG6kO.png

Those two sprite property windows are what I'm trying to do.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

孤檠 2024-11-25 01:54:55

我认为你正在寻找的东西叫做 mdi-container

但是到目前为止我见过的唯一真正的 mdi 容器(在.NET中)是一个表单......遗憾的是没有面板或类似的东西......

但如果你只是想要“窗口中的窗口”效果:只需创建新表单,将该实例的 TopLevel 属性设置为 false,然后将该实例添加到您的 form/panel/splitcontainer/与任何其他通常的控件一样

i think what you are looking for is called mdi-container

however the only real mdi container i've seen so far (in .NET) is a form ... sadly no panel or something similar...

but if you just want the "window in a window" effect: simply create your new form, set the TopLevel property of that instance to false, and add the instance to your form/panel/splitcontainer/whatever like any other usual control

孤凫 2024-11-25 01:54:55

您可以尝试使用 MDI 表单并实现 TreeView 控件,查看某种对接面板。我过去用过这个(http://sourceforge.net/projects/dockpanelsuite/)。

它非常灵活。您设置了这些停靠面板窗体之一,停靠在 MDI 窗体的左侧。它始终位于“顶部”,并且用户可以像窗体上的拆分器控件一样调整其大小。如果您愿意,它还可以具有“自动隐藏”功能,这在您的情况下可能需要也可能不需要。

然后它可以包含您的树视图,它可以加载您喜欢的所有 MDI 子窗体。

您会发现您并没有与“Windows”真正想要的行为方式作斗争,并且事情会运行得更加顺利。

You could try using an MDI form and to implement your TreeView control, check out some sort of docking panel. I've used this one in the past (http://sourceforge.net/projects/dockpanelsuite/).

It is very flexible. You set up one of these dockpanel forms, docked to the left of your MDI form. It will always be "on top" and the user can resize it exactly like the splitter control on a form. If you like, it can also has an "autohide" feature which may or may not be desirable in your case.

It can then contain you treeview, which can load all the MDI Child forms you like.

You'll find you're not fighting how "Windows" really want to behave and things will run a lot more smoothly.

吻安 2024-11-25 01:54:55

通过 Add() 方法将其放入 Panel2 的 Control 集合中,以编程方式应用坐标、锚点和停靠。

Put it into the Panel2's Control collection via the Add() method, apply coordinates, anchor and docking programmaticaly.

终难愈 2024-11-25 01:54:55

我曾经做过类似的事情,因此,我有 ReplaceControl 方法,我将其粘贴在下面:

    static public void ReplaceControl(Control ToReplace, Form ReplaceWith) {
        ReplaceWith.TopLevel=false;
        ReplaceWith.FormBorderStyle=FormBorderStyle.None;
        ReplaceWith.Show();
        ReplaceWith.Anchor=ToReplace.Anchor;
        ReplaceWith.Dock=ToReplace.Dock;
        ReplaceWith.Font=ToReplace.Font;
        ReplaceWith.Size=ToReplace.Size;
        ReplaceWith.Location=ToReplace.Location;
        ToReplace.Parent.Controls.Add(ReplaceWith);
        ToReplace.Visible=false;
    }

剩下要做的就是在表单上手动创建一些控件,作为表单的占位符。例如,使用标签。

来自 如何实现 - form-inside-a-form 具有运行时嵌入式表单切换功能?

I did similar thing once, and for that reason, I have ReplaceControl method, which I paste below:

    static public void ReplaceControl(Control ToReplace, Form ReplaceWith) {
        ReplaceWith.TopLevel=false;
        ReplaceWith.FormBorderStyle=FormBorderStyle.None;
        ReplaceWith.Show();
        ReplaceWith.Anchor=ToReplace.Anchor;
        ReplaceWith.Dock=ToReplace.Dock;
        ReplaceWith.Font=ToReplace.Font;
        ReplaceWith.Size=ToReplace.Size;
        ReplaceWith.Location=ToReplace.Location;
        ToReplace.Parent.Controls.Add(ReplaceWith);
        ToReplace.Visible=false;
    }

Only thing left to do is to create some control manually on the form, as the placeholder for your Form. Use label, for example.

From How to implement a-form-inside-a-form with runtime embedded forms switching?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文