How to auto fit/scale DBGrid's (or other similar) columns widths according to its contents?

前端 未结 8 1911
天命终不由人
天命终不由人 2021-01-04 14:11

I am trying to make a frame with a DBGrid that will serve for more than 10 tables with half of its fields as defaults, and other fields exclusive for each table

8条回答
  •  感动是毒
    2021-01-04 14:26

    For TRUEDBGRID .net you can do this:

     Private Sub AutoSizeGrid(Grid As C1.Win.C1TrueDBGrid.C1TrueDBGrid)
            For Each Sp As C1.Win.C1TrueDBGrid.Split In Grid.Splits
                For Each Cl As C1.Win.C1TrueDBGrid.C1DisplayColumn In Sp.DisplayColumns
                    Cl.AutoSize()
                Next
            Next
    End Sub
    

    For TrueDbGrid ActiveX in vb60 this (this code not include splits):

    Public Function APEXGridAutoFix(Grid As TrueOleDBGrid80.TDBGrid)
    Dim Col As TrueOleDBGrid80.Column
    For Each Col In Grid.Columns
        Col.AutoSize
    Next
    End Function
    

提交回复
热议问题