简体   繁体   English

在设计视图上调整userControl的大小

[英]Resizing a userControl on design view

I created a little UserControl and it works perfectly. 我创建了一个小的UserControl,它运行完美。

During design view in Visual Studio, I need to modify some things as the control is resized. 在Visual Studio的设计视图中,我需要在调整控件大小时进行一些修改。

Here's the control: 这是控件:

替代文字

It's a comboxBox, that is used to display the selected color; 这是一个comboxBox,用于显示选定的颜色; and a XAML usercontrol. 和XAML用户控件。 But that's not quite important. 但这不是很重要。

Basically what I want is that if someone resizes this control during design view in Visual Studio, that little black block remains 1px away from the right side of the control. 基本上我想要的是,如果有人在Visual Studio的设计视图中调整此控件的大小,则该黑色小块将保持距控件右侧1px的距离。

I have tried modifying the code in the InitializingComponent() method but it seems that you can't do that. 我尝试修改InitializingComponent()方法中的代码,但看来您无法做到这一点。

Thanks for the suggestions and help. 感谢您的建议和帮助。

You should set the child control's Anchor to Right . 您应该将子控件的AnchorRight
For more information, see MSDN . 有关更多信息,请参见MSDN

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

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