|
本帖最后由 wx0000888 于 2016-6-28 22:31 编辑
图片就不搞了, 直接上菜. 2010版哦.
自定义汇总条 + ADOTransForm(事务处理的)
1 菜单按钮, 本来想用TOOLBAR 的 但不稳定,还是内置常用控件组合最稳定了,现在正在设计成 红尘如烟的 通用系统主面板上的 漂亮大按钮,只不过缩小版罢了, 鼠标点过去漂亮是显示, 已有眉目了, 再完善完善.
2 汇总条上的自定义函数还未搞, 设想是把每个这个窗体的主要控件的汇总函数放在 表中, 等有空的时间再搞.
说到底,就是利用 columnorder 和 columnhidden
贴上自定义汇总条代码
- Public Sub frmTotalBar(strMain As String, strDetail As String, strBar As String) '自定义汇总行
- ' On Error Resume Next
- Dim ctl As Control
- Dim lngW As Long
- Dim arrControl() As String
- Dim Index As Integer
- Dim Total As Integer
- Dim frm As Object
- Dim frmBar As Object
- Dim ctlName As String
- Set frmBar = Application.Forms(strMain).Controls(strBar).Form
- Set frm = Application.Forms(strMain).Controls(strDetail).Form '
- ReDim arrControl(1 To frmBar.Controls.Count) '上标1开始
- For Each ctl In frm.Controls
- If ctl.ControlType <> acLabel Then
- ctlName = ctl.Name
- If ctl.ColumnHidden = False Then
- arrControl(ctl.ColumnOrder) = ctlName '利用数组的索引,自动排序,然后再经过后面过滤无用的,截取有用的(非隐藏的).
- End If
- End If
- Next
-
- frmBar.Box0.SetFocus '必须转移焦点,否则无法隐藏
- For Index = 1 To 20 '整理数组,有效的数组前置
- frmBar.Controls("txtControl" & Index).Visible = False
- If arrControl(Index) <> "" Then
- Total = Total + 1
- arrControl(Total) = arrControl(Index)
- frmBar.Controls("txtControl" & Total).Visible = True
- End If
- Next
- For Index = 1 To Total '过滤无用的,截取有用的(非隐藏的) , k是下标,1到k位置里面都是有用的,非隐藏的
- If frm.Controls(arrControl(Index)).ColumnWidth = -1 Then '当新建的字段,其默认屏幕显示宽度为-1,实际是1410
- frmBar.Controls("txtControl" & Index).Width = 1410 '13.2095 (1410)
- Else
- frmBar.Controls("txtControl" & Index).Width = frm.Controls(arrControl(Index)).ColumnWidth
- End If
- If Index = 1 Then
- frmBar.Controls("txtControl" & Index) = "汇总" '第一列 标题一般为 "汇总"
- lngW = 285 'Box的宽度作为起点(最左)
- Else
- lngW = lngW + frmBar.Controls("txtControl" & (Index - 1)).Width
- End If
- frmBar.Controls("txtControl" & Index).Left = lngW
- Next
- Erase arrControl() '释放内存
- Set ctl = Nothing
- Set frm = Nothing
- Set frmBar = Nothing
- End Sub
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|