mshflexgrid1 怎么实现根据字节长度自动调整列宽?
如题。我根据网上的用label控件间接地设置好像不行啊。
Public Sub AutoSizeFlexGrid(flexObject As MSHierarchicalFlexGridLib.MSHFlexGrid) Dim RsFlex As ADODB.Recordset, sngMaxWidth() As Single, sngTextWidth As Single Dim X As Integer, Y As Integer With flexObject If .Cols = 0 Then Exit Sub .Visible = False ReDim sngMaxWidth(.Cols - 1) For Y = 0 To .Rows - 1 For X = 0 To .Cols - 1 sngTextWidth = .Parent.TextWidth(Trim(.TextMatrix(Y, X))) * 1 If sngMaxWidth(X) < sngTextWidth Then sngMaxWidth(X) = sngTextWidth Next Next For X = 0 To flexObject.Cols - 1 .ColWidth(X) = sngMaxWidth(X) + 120 Next For X = 0 To .Cols - 1 Set RsFlex = flexObject.DataSource If X < RsFlex.Fields.Count And Not (RsFlex.EOF Or RsFlex.BOF) Then Select Case TypeName(RsFlex.Fields(X).value) Case "Integer", "Double", "Currency", "Byte", "Long", "Decimal", "Single" .ColAlignment(X) = flexAlignRightCenter Case Else .ColAlignment(X) = flexAlignLeftCenter End Select End If Next .Row = 0 .Col = 0 If .Rows > 1 Then .Row = 1 .ColSel = .Cols - 1 .Visible = True End With End Sub