vba 在 ms access 2010 中适应各种屏幕设置的形式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20365450/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 00:47:19  来源:igfitidea点击:

fitting forms to various screen settings in ms access 2010

vbams-accessaccess-vbams-access-2010

提问by CodeMed

I have a set of two nested navigation subforms in an ms access 2010 database. The problem is that, when different users on different machines view the database through different screen resolutions and text size settings, the forms can have silly wastes of screen real estate, such as in the following image:

我在 ms access 2010 数据库中有一组两个嵌套的导航子表单。问题是,当不同机器上的不同用户通过不同的屏幕分辨率和文本大小设置查看数据库时,表单可能会浪费屏幕空间,如下图所示:

How do I set the width and height of each navigation subform so that each of the two navigation subforms has a small inset (30 pixels?) at the right and bottom, assuming that the left and top are fixed?

假设左侧和顶部是固定的,如何设置每个导航子窗体的宽度和高度,以便两个导航子窗体中的每一个在右侧和底部都有一个小插图(30 像素?)?

Here is the code that I worked up so far, but it pushes things too far to the right and to the bottom, without leaving the insets that I need at the right and bottom:

这是我到目前为止处理的代码,但它把东西推到右边和底部太远了,而没有在右边和底部留下我需要的插图:

Main form (this is the outermost form):  

Private Sub Form_Resize()
    On Error Resume Next
    Me.NavigationSubform.Width = Me.WindowWidth - (Me.NavigationSubform.Left + 10)
    Me.NavigationSubform.Height = Me.WindowHeight - (Me.NavigationSubform.Top + 10)
End Sub

FindClientsNavigation form (this is the second level form):  

Private Sub Form_Resize()
    On Error Resume Next
    Me.NavigationSubform.Width = Me.WindowWidth - (Me.NavigationSubform.Left + 10)
    Me.NavigationSubform.Height = Me.WindowHeight - (Me.NavigationSubform.Top + 10)
End Sub

I uploaded a simplified version of the database with enough to recreate the problem at this file sharing site.

我上传了一个简化版的数据库,足以在这个文件共享站点上重现这个问题。

If you want to recreate the problem on your pc after downloading the database, you can set the windows text size property using the following dialog in the control panel:

如果您想在下载数据库后在您的电脑上重现该问题,您可以使用控制面板中的以下对话框设置 windows 文本大小属性:

回答by Chris Rolliston

Instead of messing about with code, set the HorizontalAnchorand VerticalAnchorproperties of the subform controls appropriately at designtime, i.e. to Both. The default is for the horizontal anchor to be left only and the vertical anchor to be top only; setting to left-and-right and top-and-bottom will mean the control stretches accordingly when its parent resizes.

不要乱用代码,而是在设计时适当地设置子表单控件的HorizontalAnchorVerticalAnchor属性,即设置为Both。默认是水平锚点只在左边,垂直锚点只在顶部;设置为 left-and-right 和 top-and-bottom 将意味着控件在其父级调整大小时相应地拉伸。

回答by Dzintars

There is simple navigation available in ribbon. See the picture above.

功能区中有简单的导航。见上图。

enter image description here

在此处输入图片说明