【CSDN】【如何根据MSFlexGrid控件中内容的字符长度自动调整列宽,保证所有字符可见】
Dim Max As Integer
Dim i As Integer
Dim j As Integer
For j = 0 To MSFlexGrid1.Cols - 1
Max = 0
For i = 0 To MSFlexGrid1.Rows - 1
If Len(Trim(MSFlexGrid1.TextMatrix(i, j))) > Max Then Max = Len(Trim(MSFlexGrid1.TextMatrix(i, j)))
Next i
MSFlexGrid1.ColWidth(j) = Max * 300
Next j