调整子表格的大小 [英] Adjust size of Child Forms

查看:113
本文介绍了调整子表格的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有带Visual Basic 2010的Windows7.

在我的应用程序中,我有一个父表单,名为:Form1
承载两个子窗体:Child1Form1和ChildForm2

我编写了以下代码:

I have Windows 7 with Visual Basic 2010.

In my application I have a parent form named: Form1
that hosts two Child forms: Child1Form1 and ChildForm2

I have written the following code:

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim DeskHeight As Integer : Dim DeskWidth As Integer
        DeskWidth = Screen.PrimaryScreen.WorkingArea.Width
        DeskHeight = Screen.PrimaryScreen.WorkingArea.Height
        Me.Show()
        Me.Size = New Size(DeskWidth, DeskHeight)
        Dim Location As Point : Location = New System.Drawing.Point(0, 0)
        Me.Location = Location
        Location = New System.Drawing.Point(0, 0)
        Me.Location = Location
        '--------------------------
        ChildForm2.MdiParent = Me
        Childform2.Location = New Point(175, 0)
        Childform2.Show()
        Dim ChildForm2Width, ChildForm2Height As Integer
        ChildForm2Width = DeskWidth - 175
        Childform2.Size = New Size(ChildForm2Width, DeskHeight)
        Location = New System.Drawing.Point(175, 0)
        Childform2.Location = Location
        ChildForm2.Text = "Child2"
        '-----------------------------
        ChildForm1.MdiParent = Me
        Childform1.Show()
        Childform1.Size = New Size(175, DeskHeight)
        Location = New System.Drawing.Point(0, 0)
        Childform1.Location = Location

    End Sub
End Class




我的问题是如何使两个子窗体适合于Form1.
如果按照我的设定,Childform1的宽度为175,则Childform2的宽度
应该是:

Deskwidth-175

但这是行不通的.子窗体的工作区较小.
我对子窗体的高度有相同的问题.
我该如何计算子窗体的工作区域(高度-宽度),以免出现滚动条?




My problem is how to make the two child forms fit inside Form1.
If Childform1 has a width of 175 as I set, then Childform2 width
should be:

Deskwidth-175

But this does''nt work. The working area for the child forms is smaller.
I have the same problem for the height of the child forms.
How can I calculate the working area (height -width) of the child forms so no scroll bars appeare ?

推荐答案

我不完全关注您,但是听起来好像您想将两个子窗口与父窗口放置在相同的空间中,并且想在两个窗口之间进行划分(尽管不一定要分成两半).您可能需要研究ClientRectangle,它将为您提供Window的面积减去标题栏之类的东西.
I don''t follow you exactly, but it sounds like you want to fit the two child windows in the same space as the parent window, and you want to split the space between the two of them (though not necessarily in two halves). You might want to look into ClientRectangle, which will give you the area of a Window minus things like the title bar.


这是因为父级的容器大小(实际工作空间)
小于您正在使用的screen.workingarea.因此,您
需要获取父容器的容器大小.

此处
This is because the containersize (actual working space) of your parent
is smaller than the screen.workingarea you''re using. Therefore you''ll
need to get the containersize of the parent.

Check here
for the answer to a similar problem.


您必须测量表单的内容,知道它是否适合您提供的区域,或者是否需要滚动条.
You have to measure the content of the form, to know if it''s going to fit in the area you provide, or if it will require scroll bars.


这篇关于调整子表格的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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