打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
两个MSFlexGrid的函数 点击表头排序函数以及依据内容自动调整列宽为最合适的宽度
Public Const STR_SORT_ASC = "△"
Public Const STR_SORT_DESC = "▽"

'//排序函数
Public Sub Sort(sgrd As MSHFlexGrid, y As Single)
 With sgrd
 If y >= .RowPos(0) And y < .RowPos(1) Then
 If .Tag <> "" Then
 If .Tag <> .Col Then
 .TextMatrix(0, .Tag) = Left(.TextMatrix(0, .Tag), Len(.TextMatrix(0, .Tag)) - 1)
 End If
 End If
 
 If Right(.TextMatrix(0, .Col), 1) = STR_SORT_ASC Then
 .Sort = flexSortGenericAscending
 .TextMatrix(0, .Col) = Replace(.TextMatrix(0, .Col), STR_SORT_ASC, STR_SORT_DESC)
 ElseIf Right(.TextMatrix(0, .Col), 1) = STR_SORT_DESC Then
 .Sort = flexSortGenericDescending
 .TextMatrix(0, .Col) = Replace(.TextMatrix(0, .Col), STR_SORT_DESC, STR_SORT_ASC)
 Else
 .Sort = flexSortGenericDescending
 .TextMatrix(0, .Col) = .TextMatrix(0, .Col) & STR_SORT_ASC
 End If
 .Tag = .Col
 End If
 End With
End Sub


'//自动调整Grid各列列宽为最合适的宽度
Public Sub AdjustColWidth(frmCur As Form, gridCur As Object, Optional bNullRow As Boolean = True, Optional dblIncWidth As Double = 0)
'--------------------------------------------------------------------
'功能:
'               自动调整Grid各列列宽为最合适的宽度
'参数:
'               [frmCur]......................当前工作窗体
'               [gridCur].....................当前要调整的Grid
'--------------------------------------------------------------------
Dim i, j As Integer
Dim dblWidth As Double

With gridCur
   For i = 0 To .Cols - 1
      dblWidth = 0
      If .ColWidth(i) <> 0 Then
         For j = 0 To .Rows - 1
            If frmCur.TextWidth(.TextMatrix(j, i)) > dblWidth Then
               dblWidth = frmCur.TextWidth(.TextMatrix(j, i))
            End If
         Next
'        .ColWidth(i) = dblWidth + dblIncWidth + 100
      End If
   Next
End With

End Sub

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
MSHFlexGrid控件自动调整列宽应用
DB2中的rank()
PHP array
VB-MSHFlexGrid常用的功能代码
VB中VSPrinter
二维数组进行排序
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服