設為首頁收藏本站Access中國

Office中國論壇/Access中國論壇

 找回密碼
 注冊

QQ登錄

只需一步,快速開始

12下一頁
返回列表 發(fā)新帖
查看: 8421|回復: 11
打印 上一主題 下一主題

另類控件自適應窗體

[復制鏈接]
跳轉到指定樓層
1#
發(fā)表于 2005-3-31 01:52:00 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
如圖



本帖子中包含更多資源

您需要 登錄 才可以下載或查看,沒有帳號?注冊

x
分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享分享 分享淘帖 訂閱訂閱
2#
發(fā)表于 2005-3-31 02:44:00 | 只看該作者
怎么做的,如何實現? 想知道
3#
發(fā)表于 2005-3-31 06:47:00 | 只看該作者

回復:(goodidea)另類控件自適應窗體



在Resize事件中通過遍歷窗體控件進行判斷和設置,變量 i 記錄第幾行,, j 記錄當前變量的右邊位置。

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_標簽.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 & "_標簽").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 & "_標簽").Top = i * 500 + 100

            Controls(ctl.Name & "_標簽").Left = j + 50

            ctl.Top = i * 500 + 100

            ctl.Left = Controls(ctl.Name & "_標簽").Left + Controls(ctl.Name & "_標簽").Width

            If 50 + Controls(ctl.Name & "_標簽").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

本帖子中包含更多資源

您需要 登錄 才可以下載或查看,沒有帳號?注冊

x
4#
發(fā)表于 2005-3-31 18:08:00 | 只看該作者
高,的確高
5#
發(fā)表于 2008-5-18 12:59:43 | 只看該作者
高,的確高
6#
發(fā)表于 2008-5-20 10:38:03 | 只看該作者
[:31]
7#
發(fā)表于 2010-4-1 17:07:16 | 只看該作者
高,頂
8#
發(fā)表于 2010-5-17 23:22:52 | 只看該作者
向高手學習!
9#
發(fā)表于 2010-7-13 21:51:03 | 只看該作者
頂,頂
10#
發(fā)表于 2010-8-2 09:00:24 | 只看該作者
向高手學習
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則

QQ|站長郵箱|小黑屋|手機版|Office中國/Access中國 ( 粵ICP備10043721號-1 )  

GMT+8, 2024-10-23 06:30 , Processed in 0.100592 second(s), 34 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回復 返回頂部 返回列表