Winforms MDI客户区的大小/位置 [英] Size/Location of Winforms MDI Client Area

查看:94
本文介绍了Winforms MDI客户区的大小/位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MDI表单内部是一个托管mdi子表单的客户区.我如何知道该面积有多大?到目前为止,我能想到的最好的方法是找到父级潜在客户区域的总大小(mdiparent.ClientRectangle),然后减去从客户区域中拿走的工具栏等组件的大小.有更好的方法吗?

Inside an MDI form is a client area that hosts the mdi child forms. How do I find out how big that area is? The best I can come up with so far is finding the total size of the parent's potential client area (mdiparent.ClientRectangle) and then subtracting off the sizes of components like toolbars, etc that take away from the client area. Is there a better way?

推荐答案

表单上没有可用于访问MDI客户端窗口的属性.但是您可以像这样找到它:

There is no property on a form that gives you access to the MDI client window. But you can find it back like this:

public MdiClient GetMdiClientWindow() {
  foreach (Control ctl in this.Controls) {
    if (ctl is MdiClient) return ctl as MdiClient;
  }
  return null;
}

从那里开始,只需使用其Size属性即可.

From there, just use its Size property.

这篇关于Winforms MDI客户区的大小/位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆