简体   繁体   English

C#Designer中的粘贴粘贴停靠控件

[英]Copy-pasting Docked Control in C# Designer

I am designing the UI of my program with a TableLayoutPanel, with each control docked in its cell with Dock = Fill . 我正在使用TableLayoutPanel设计程序的UI,每个控件都通过Dock = Fill停靠在其单元格中。 Since a lot of the controls are similar, I want to use copy-paste to populate the layout. 由于很多控件都相似,因此我想使用复制粘贴来填充布局。 However, the newly pasted control is put in the bottom -left cell by default. 但是,默认情况下,新粘贴的控件放置在左下角的单元格中。 Furthermore, since it is docked, I cannot move it in the designer, so the only way I could put it in the correct cell is by setting Dock = None , drag it, then setting Dock = Fill again. 此外,由于它是停靠的,所以我无法在设计器中移动它,因此我可以将其放置在正确的单元格中的唯一方法是设置Dock = None ,拖动它,然后再次设置Dock = Fill This is very annoying, and to some extent defeats the purpose to use copy-paste in the first place (to avoid forgetting to set Dock ). 这非常烦人,并且在某种程度上破坏了首先使用复制粘贴的目的(以避免忘记设置Dock )。 Are there any better ways I can create such a layout? 有什么更好的方法可以创建这样的布局?

I just found out that, when put into a TableLayoutPanel, the control has a Cell property. 我刚刚发现,当放入TableLayoutPanel中时,该控件具有Cell属性。 Modifying it allows me to move the control within the TableLayoutPanel without first undocking it. 对其进行修改,使我可以在TableLayoutPanel中移动控件,而无需先取消对接。

Of course, Hans Passant's suggestion of first moving the controls, then mass-set the Dock property also works. 当然,汉斯·帕桑特(Hans Passant)的建议是先移动控件,然后大规模设置Dock属性也可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM