[英]How to change size of panel control on resize of parent form
I am using this code to change size of a panel
control for maximize
and normal state
, and it's working fine, but I am not getting how to re-size panel according to my background image when the user will re-size the form other than minimize,maximize and normal state, ie using the mouse.我正在使用此代码来更改
panel
控件的大小以获得maximize
和normal state
,并且它工作正常,但是当用户重新调整表单大小时,我不知道如何根据我的背景图像重新调整面板大小而不是最小化、最大化和正常状态,即使用鼠标。 how do I do this using some calculation code or any other way?我如何使用一些计算代码或任何其他方式来做到这一点?
private void ParentHome_ClientSizeChanged(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Maximized)
{
this.Panel1.Size = new System.Drawing.Size(227, 324);
this.Panel1.Location = new System.Drawing.Point(69, 223);
}
else if (this.WindowState == FormWindowState.Normal)
{
this.Panel1.Size = new System.Drawing.Size(198, 289);
this.Panel1.Location = new System.Drawing.Point(60, 193);
}
}
You don't need to handle any event.您不需要处理任何事件。 Just use the
Anchor
property:只需使用
Anchor
属性:
Panel1.Anchor = AnchorStyles.Left | AnchorStyles.Top |
AnchorStyles.Right | AnchorStyles.Bottom;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.