.NET vs Java Movie Trailer

No Comments

Funny stuff.  LOL

Easy way to autosize columns of a detail listview

No Comments

Following code will resize the columns of a listview to either the length of the column name or the length of the biggest item in that column.

Private Sub AutoSizeListviewCols(ByVal lv As ListView)
 Dim colHeader As ColumnHeader
 Dim width1, width2 As Integer

 Dim colHeaderCollection As ListView.ColumnHeaderCollection = lv.Columns
 For i As Int32 = 0 To colHeaderCollection.Count - 1

 colHeader = colHeaderCollection(i)
 colHeader.Width = -1
 width1 = colHeader.Width
 colHeader.Width = -2
 width2 = colHeader.Width

 colHeader.Width = CInt(If(width2 < width1, width1, width2))
 Next

 End Sub