设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

12下一页
返回列表 发新帖
查看: 7944|回复: 11
打印 上一主题 下一主题

另类控件自适应窗体

[复制链接]
跳转到指定楼层
1#
发表于 2005-3-31 01:52:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
如图



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2005-3-31 02:44:00 | 只看该作者
怎么做的,如何实现? 想知道
3#
发表于 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#
发表于 2005-3-31 18:08:00 | 只看该作者
高,的确高
5#
发表于 2008-5-18 12:59:43 | 只看该作者
高,的确高
6#
发表于 2008-5-20 10:38:03 | 只看该作者
[:31]
7#
发表于 2010-4-1 17:07:16 | 只看该作者
高,顶
8#
发表于 2010-5-17 23:22:52 | 只看该作者
向高手学习!
9#
发表于 2010-7-13 21:51:03 | 只看该作者
顶,顶
10#
发表于 2010-8-2 09:00:24 | 只看该作者
向高手学习
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-17 17:10 , Processed in 0.179749 second(s), 34 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表