AutoSize of Column In MshflexGrid with multiple band

xiaoxiao2021-03-06  56

Public Function FG_AutosizeCols (myGrid As Long = -1 MSHFlexGrid, _ Optional ByVal lFirstCol As, _ Optional ByVal lLastCol As Long = -1, _ Optional bCheckFont As Boolean = False) Dim lCol As Long, lRow As Long, lCurCol As Long, lCurRow As Long Dim lCellWidth As Long, lColWidth As Long Dim bFontBold As Boolean Dim dFontSize As Double Dim sFontName As String If bCheckFont Then 'save the forms font settings bFontBold = Me.FontBold sFontName = Me.FontName dFontSize = Me.FontSize End If With myGrid .Redraw = False If bCheckFont Then lCurRow = .Row lCurCol = .Col End If If lFirstCol = Then lFirstCol = 0 'Special for MSHFlexGrid with multiple bands If lLastCol -1 = -1 Then lLastCol = 0 for i = 0 To .Bands - 1 Llastcol = Llastcol .cols (i) Next i lLastCol = lLastCol - 1 End If For lCol = lFirstCol To lLastCol lColWidth = 0 If bCheckFont Then .Col = lCol For lRow = 0 To .Rows - 1 If bCheckFont Then .Row = lRow Me.FontBold = .CellFontBold Me.FontName = .CellFontName Me.FontSize = .CellFontSize End If lCellWidth = Me.TextWidth (.TextMatrix (lRow, lCol)) If lCellWidth> lColWidth Then lColWidth = lCellWidth Next lRow .ColWidth (lCol) =

转载请注明原文地址:https://www.9cbs.com/read-112952.html

New Post(0)