MSHFlexGrid控件的属性设置不支持,不过你可以设置 AllowUserResizing属性为
1-Columns 这样用户可以自己调整列长度,
如果你要编程实现的话,我有一个比较笨的法子,
你设置MSHFlexGrid控件的列宽时可以根据表中字段的长度和MSHFlexGrid控件的字体设置按照固定的比例设置,
例如原先我曾经设置一列的宽度为 
rs.Fields(0).DefinedSize * 200 ---- 我用的是宋体9号字,每个字节设置宽度为200缇,这个数字你可以换算,也可以根据字体大体上使用固定的值,当然了,如果你要使列宽不小于标题宽度,不超出 比如说(最长字符数+1)个字符的话那就需要进行判断取值了如何应用就看你自己了

解决方案 »

  1.   

    rs.Fields(0).DefinedSize * 200  ---200 这个数字可能不准确,记不清了
      

  2.   

    要写程序的,假设你的行头是用的表中的字段名,程序是这样的:
        Dim rs As New ADODB.RecordSet
        Dim fld As ADODB.Field
        '......    'Setup the hflxResults headings
        For Each fld In rs.Fields
            hflxResults.Text = fld.Name
            hflxResults.ColAlignment(hflxResults.Col) = 1
            hflxResults.ColWidth(hflxResults.Col) = Me.TextWidth(fld.Name & "AA")'加宽两个字符
            If hflxResults.Col < rs.Fields.Count - 1 Then
               hflxResults.Col = hflxResults.Col + 1
            End If
        Next fld
    如果是自定义的列头,可以写到一个数组里,方法类似,用的是TextWidth~~
      

  3.   

    TextWidth Method
    Applies To   See AlsoReturns the width of a text string as it would be displayed in the current font.Syntax[nWidth =] [FormSet.]Object.TextWidth(cText)ArgumentsnWidthReturns a value in pixels specifying the width of the text string.cTextSpecifies the character string for which the text width is determined.ResThe TextWidth method determines the amount of horizontal space required to display cText.