oh...okay. saya coba dulu...makasih atas infonya ya.. :)
--- In [email protected], "A. Numairullah"
<[EMAIL PROTECTED]> wrote:
>
>
> Tambahkan fungsi ini di modul, utk memicunya
>
> Set Datagrid1.Datasource = rsTest
>
> SetDataGridColumnWidth Datagrid1
>
>
>
> Function SetDataGridColumnWidth(grd As DataGrid)
>
> Dim InnerLoopCount As Long
> Dim OuterLoopCount As Long
> Dim lngLongestLen As Long
> Dim sLongestString As String
> Dim lngColWidth As Long
> Dim szCellText As String
>
> With grd
> ' baca tiap kolom
> For OuterLoopCount = 0 To .VisibleCols - 1
>
> sLongestString = ""
> lngLongestLen = 0
>
> ' baca tiap baris
> For InnerLoopCount = 1 To .VisibleRows - 1
>
> .Row = InnerLoopCount
>
> szCellText = .Columns(OuterLoopCount)
> '.TextMatrix(InnerLoopCount, OuterLoopCount)
>
>
> If Len(szCellText) > lngLongestLen Then
> lngLongestLen = Len(szCellText)
> sLongestString = szCellText
> End If
>
> Next
>
> lngColWidth = .Parent.TextWidth(sLongestString)
>
> 'add 100 for more readable spreadsheet
> .Columns(OuterLoopCount).Width = lngColWidth + 200
> Next
> End With
> End Function
>