Friday, June 01, 2007

Auto Size Columns in the DataGrid ?

do u want to Auto Size Columns in the DataGrid ? here is the code

Public Sub AutoSizeGrid(ByVal Grid As DataGrid)
Dim t As Type = grdInfo.GetType
Dim m As MethodInfo = t.GetMethod("ColAutoResize", _
BindingFlags.NonPublic Or BindingFlags.Instance)
Dim start As Integer
start = grdInfo.FirstVisibleColumn
Dim i As Integer = 0
While i < grdInfo.VisibleColumnCount OrElse i = 0
m.Invoke(Grid, New Object() {i + start})
i = i + 1
End While
Catch ex As Exception
m_parentForm.imcMessege.LogErrorMessage(Me, ex)
End Try
End Sub

No comments: