如何确保控件不在面板内?
我有几个面板占用了窗体上的大量空间,有时当我将新控件拖放到窗体上时,Visual Studios 会将该控件放入该面板中,这是我不想要的。有什么方法可以确保控件不在面板内部?
I have a few panels that take up a lot of space on my form, and sometimes when I drop a new control onto the form, Visual Studios will put that control inside that panel, which is something I do not want. Is there any way to be sure that a control is not inside of a panel?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用文档大纲视图查看层次结构树。
单击“查看”→“其他窗口”→“文档大纲”。
默认快捷键是 Ctrl + W、U。
另外:单击设计器中的控件,然后单击多次 Esc 键将在层次结构中向上移动,始终选择父级,直到选择根窗体/控件。
这可能是一种直观地查看某个控件包含在哪个控件中的方法。
Use the Document Outline view to see a tree of the hierarchy.
Click "View" → "Other Windows" → "Document Outline".
The default shortcut is Ctrl + W, U.
In addition: Clicking a control in the designer and then clicking multiple times the Esc key will travel up in hierarchy, always selecting the parent, until the root form/control is being selected.
This could be a way to see visually which control a certain control is contained inside.
自从我完成 winform 以来已经有一段时间了,但我相信面板中的项目将具有相对于面板原点的 left 和 top 属性。
如果我没记错的话,你可以检查一下控件的位置,应该立即清楚它们是否与表单本身相关。
It has been a while since I've done winforms, but I believe that an item in a panel will have left and top properties that are relative to the origin point of the panel.
If my recollection is correct, then, you can inspect the location of the control, and it should be immediately clear that they are or are not relative to the form itself.
您可以查看
Form1.Designer.cs
文件,并准确查看哪个容器是控件的父级。You could look in the
Form1.Designer.cs
file, and see exactly what container is the parent of the control.