Office中國(guó)論壇/Access中國(guó)論壇
標(biāo)題:
另類控件自適應(yīng)窗體
[打印本頁(yè)]
作者:
goodidea
時(shí)間:
2005-3-31 01:52
標(biāo)題:
另類控件自適應(yīng)窗體
如圖
[attach]9673[/attach]
作者:
ui
時(shí)間:
2005-3-31 02:44
怎么做的,如何實(shí)現(xiàn)? 想知道
作者:
Trynew
時(shí)間:
2005-3-31 06:47
標(biāo)題:
回復(fù):(goodidea)另類控件自適應(yīng)窗體
[attach]9676[/attach]
在Resize事件中通過(guò)遍歷窗體控件進(jìn)行判斷和設(shè)置,變量 i 記錄第幾行,, j 記錄當(dāng)前變量的右邊位置。
Private Sub Form_Load()
Dim ctl As Control
For Each ctl In Me.Controls
If Not TypeOf ctl Is Label And ctl.Name <> "BZ" Then
ctl.Tag = ctl.Width
End If
Next
End Sub
Private Sub Form_Resize()
Echo False
Dim i As Integer, j As Integer, ctl As Control, ctlLast As Control
Me.Width = Me.InsideWidth - 50
Me.BZ.Left = Me.InsideWidth - Me.BZ.Width - 100
Me.BZ_標(biāo)簽.Left = Me.BZ.Left
Me.BZ.Height = Me.InsideHeight - 500
For Each ctl In Me.Controls
If Not TypeOf ctl Is Label And ctl.Name <> "BZ" Then
If j <> 0 And j + 50 + Controls(ctl.Name & "_標(biāo)簽").Width + Val(ctl.Tag) > Me.InsideWidth - Me.BZ.Width - 100 Then
j = 0
Me.主體.Height = Me.主體.Height + 1000
i = i + 1
If Not ctlLast Is Nothing Then ctlLast.Width = Me.InsideWidth - Me.BZ.Width - 100 - ctlLast.Left - 100
End If
Controls(ctl.Name & "_標(biāo)簽").Top = i * 500 + 100
Controls(ctl.Name & "_標(biāo)簽").Left = j + 50
ctl.Top = i * 500 + 100
ctl.Left = Controls(ctl.Name & "_標(biāo)簽").Left + Controls(ctl.Name & "_標(biāo)簽").Width
If 50 + Controls(ctl.Name & "_標(biāo)簽").Width + Val(ctl.Tag) > Me.InsideWidth - Me.BZ.Width - 100 Then
ctl.Width = Me.InsideWidth - Me.BZ.Width - 100 - ctl.Left - 100
Else
ctl.Width = Val(ctl.Tag)
End If
Set ctlLast = ctl
j = ctl.Left + ctl.Width
End If
Next
Me.主體.Height = Me.InsideHeight
Echo True
End Sub
作者:
ui
時(shí)間:
2005-3-31 18:08
高,的確高
作者:
7777777
時(shí)間:
2008-5-18 12:59
高,的確高
作者:
yori2007
時(shí)間:
2008-5-20 10:38
[:31]
作者:
ICEMAN
時(shí)間:
2010-4-1 17:07
高,頂
作者:
li08hua
時(shí)間:
2010-5-17 23:22
向高手學(xué)習(xí)!
作者:
df
時(shí)間:
2010-7-13 21:51
頂,頂
作者:
ny66
時(shí)間:
2010-8-2 09:00
向高手學(xué)習(xí)
作者:
Access_study
時(shí)間:
2018-3-12 07:40
窗體和控件根據(jù)屏幕大小,自動(dòng)適應(yīng)。
作者:
88189746
時(shí)間:
2021-5-1 17:04
學(xué)習(xí)了,謝謝
歡迎光臨 Office中國(guó)論壇/Access中國(guó)論壇 (http://ctxi.cn/)
Powered by Discuz! X3.3