如何调整并排控制在MS Access 2007 [英] How to resize side by side controls in MS ACCESS 2007

查看:472
本文介绍了如何调整并排控制在MS Access 2007的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

予具有其中有各种领域,为前一种形式。两个文本框并排。 这2文本框有锚固性能左侧,顶部和其他权利,顶部。

I have a form in which there are various fields, for ex. Two textboxes are side by side. These 2 textbox have anchor property left,top and other right,top.

现在,当我调整窗体控件对齐到左和其他文本框右侧。 但是,当如屏幕最大化它留下在这两个文本框之间的空白。

Now when I resize the form the controls are aligned to left and the other textbox to right. But when as screen is maximized it leaves a blank space in between these two textboxes.

于是我做了两个文本框两个锚财产,无论是控制重叠。

So then I made the anchor property of both textbox to both,both the controls overlapped.

PS:工作在MS Access 2007年。 上述固定属性为水平,垂直

PS: working on MS ACCESS 2007. anchoring property above is Horizontal, Vertical

编辑:在普通窗口

_______________________Min最大关闭 _

_______________________Min Max Close_

| TEXTBOX将First_Name LAST_NAME TEXTBOX |

| First_Name TEXTBOX Last_Name TEXTBOX |

|_______________________________|

|_______________________________|

在最大化整个屏幕它给了我

When Maximized to whole screen it gives me

_____________________________________Min最大关闭 _

_____________________________________Min Max Close_

| TEXTBOX将First_Name .............................姓氏TEXTBOX |

| First_Name TEXTBOX ............................. Last_Name TEXTBOX |

|______________________________________________|

|______________________________________________|

和我需要这种方式如下

_____________________________________Min最大关闭 _

_____________________________________Min Max Close_

| ˚F国税局t_N火焰TEXTBOX ........ L,以t_N AME TEXTBOX |

| F i r s t_N a m e T E X T B O X ........ L a s t_N a m e T E X T B O X |

|______________________________________________|

|______________________________________________|

我想通过做这一切解释,因为我不能上传图片,比较遗憾的是......

I am trying to explain by doing all this as I am not allowed to upload a image, Sorry for that....

推荐答案

粘贴以下code到表单中,更改字段名称,看看会发生什么。这两个字段将成长为你增加表格的宽度,同时保持自己的锚。注:我更新了3/3来处理字段标签

Paste the following code into your form, change the field names, and see what happens. The two fields will 'grow' as you increase the form width, yet maintain their Anchor. Note: I updated on 3/3 to handle the field labels.

Option Compare Database
Option Explicit

Dim fviInsideWidth  As Integer
Dim fviSaveInsideWidth  As Integer
Dim fviFormWidth    As Integer
Dim fviFldWidth     As Integer
Dim fviFieldGap     As Integer
Dim fviRemainder    As Integer
Dim fviLblWidth     As Integer
Dim fviRLblToTxt    As Integer
Dim fvstrLLabel     As String
Dim fvstrRLabel     As String

Private Sub Form_Open(Cancel As Integer)
    fviSaveInsideWidth = Me.InsideWidth
    fviInsideWidth = Me.InsideWidth
    fviFormWidth = Me.Width
    fviFldWidth = Me.fldLeft.Width + Me.fldRight.Width
    fviRemainder = fviInsideWidth - fviFldWidth
    fviFieldGap = Me.fldRight.Left - (Me.fldLeft.Left + Me.fldLeft.Width)
    fvstrLLabel = Me.fldLeft.Controls.Item(0).Name
    fvstrRLabel = Me.fldRight.Controls.Item(0).Name
    fviLblWidth = Me.Controls(fvstrRLabel).Width
    fviRLblToTxt = Me.fldRight.Left - Me.Controls(fvstrRLabel).Left
    'Debug.Print "Open - InsideWidth = " & fviInsideWidth & "  Fields: " & fviFldWidth & "  Remainder: " & fviRemainder
    'Debug.Print "Open - Form Width  = " & Me.Width & vbTab & "Diff = " & fviInsideWidth - fviFormWidth
End Sub

Private Sub Form_Close()
    Me.fldLeft.Width = fviFldWidth
    Me.fldRight.Width = fviFldWidth
    Me.InsideWidth = fviSaveInsideWidth
End Sub


Private Sub Form_Resize()
    Dim ifldWidth   As Integer
    Dim ifrmWidth   As Integer
    fviInsideWidth = Me.InsideWidth
    ifrmWidth = fviInsideWidth - 1110
    Me.Width = ifrmWidth
    ifldWidth = Int((fviInsideWidth - fviRemainder) / 2)
    Me.fldLeft.Width = ifldWidth
    Me.fldRight.Left = Me.fldLeft.Left + Me.fldLeft.Width + fviFieldGap
    Me.Controls(fvstrRLabel).Left = Me.fldRight.Left - fviRLblToTxt
    Me.fldRight.Width = ifldWidth
    'Debug.Print "Resize - InsideWidth = " & fviInsideWidth & vbTab & "Form Width = " & Me.Width & " Flds: " & ifldWidth & " Right=" & Me.fldLeft.Left + Me.fldLeft.Width + fviFieldGap
    'Debug.Print "Resize Form: " & Me.Width & " Flds: " & ifldWidth
    Me.Repaint
End Sub

这篇关于如何调整并排控制在MS Access 2007的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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