我对 VFP 的 Grid 有一个说法:VFP 中最诡异的控件。
有很多人因为各种原因以使用 VFP 为“耻”。尤其是 Grid 又是最常用的控件之一,它的各种“特征”好像都是 VFP 独有的。因此,才有了下面的代码,使 VFP Grid 看上去不像是 VFP Grid:
基于 Grid 基类创建一个自定义基类,并添加一个名为“Mask”的自定义方法:
If !PemStatus(This.Parent, [tq_shape], 5)
This.Parent.NewObject([tq_shape], [Shape])
Else
Thisform.LockScreen = .T.
This.Parent.tq_shape.visible = .F.
EndIf
With This.Parent.tq_shape As Shape
.visible = .T.
.BackColor = This.BackColor
.Bordercolor = This.BackColor
.BorderWidth = 0
.Top = This.Top + This.HeaderHeight + 1
.Left = This.left
.width = 0
For m.i = 1 To This.ColumnCount
Try
If This.Columns(m.i).Visible And ;
This.Columns(m.i).Width <> 0 And ;
Objtoclient(This.Columns(m.i).Objects(1), 3) <> 0
.Left = .Left + This.Columns(m.i).Width + 1
Endif
Catch
Endtry
Endfor
.Left = .Left + Iif(This.RecordMark = .T., 10, 0) + 1
m.lnWidth = This.Width + This.left - .Left - Iif(Inlist(This.ScrollBars, 2, 3), Sysmetric(5), 0) - 2
If m.lnWidth > 0
.Width = m.lnWidth
Else
.Width = 0
EndIf
.Height = This.Height - This.HeaderHeight - Iif(InList(This.ScrollBars, 1, 3), Sysmetric(8), 0) - 3
Thisform.LockScreen = .F.
Endwith
然后,在控件的 Resize、Refresh、Scrolled 执行时,调用这个 Mask 方法。适当的 Grid 属性设置,能使其外观更趋完美......
试试这个 VFP Grid 的“美容手术”?
Follow me,认识不一样的 VFP !
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有