I have a listview and by default it is set to large icons, no problems there. But if giving the user a choice I would liek to see details in the options. I have it set to switch between icons and details but in details mode there is a lot of spacing in the first column. Image attached. The code is below showing how I am loading the listview. Also why so much vertical spacing as well.
And here is the listview click event I change to details.Code:Public Sub ListFoldersFiles(ByVal path As String, ByVal lvTemp As ListView, ByVal imgLtemp As ImageList) ' Create a reference to the current directory. Dim di As New DirectoryInfo(path) If Directory.Exists(di.ToString) Then ' Create an array representing the files in the current directory. Dim fi As FileInfo() = di.GetFiles() Dim fiTemp As FileInfo Array.Sort(fi, New compclass(SortOrder.Ascending)) lvTemp.Items.Clear() ' Loop through each file in the directory For Each fiTemp In fi Dim strImageKey As String = String.Empty Try ' gets the icon from file Dim ico As Icon = Icon.ExtractAssociatedIcon(path & fiTemp.Name) If ico IsNot Nothing Then Dim bmp As Bitmap = ico.ToBitmap() strImageKey = bmp.GetHashCode.ToString imgLtemp.Images.Add(strImageKey, bmp) Form1.ImageList3.Images.Add(strImageKey, bmp) End If Catch ex As Exception End Try ' split the extension off so we can use just the text. Dim rFileName As Array = Split(fiTemp.Name, ".") Dim fname As String = rFileName(0) ' add full name to tag so we can call it later seeing how we ' don't use the extension for the text. Dim item As New ListViewItem(fname, imgLtemp.Images.Count - 1) With {.Tag = path & fiTemp.Name} lvTemp.Items.Add(item) If Form1.tvFolders.SelectedNode.Name <> "Jackson County" Then item.SubItems.Add(Form1.tvFolders.SelectedNode.Parent.Name) item.SubItems.Add(fiTemp.Name) End If Next fiTemp End If End Sub
Code:Private Sub MnuDetails_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MnuDetails.Click lvFiles.SmallImageList = ImageList3 lvFiles.View = View.Details ' Select the item and subitems when selection is made. lvFiles.FullRowSelect = True ' Sort the items in the list in ascending order. lvFiles.Sorting = SortOrder.Ascending lvFiles.Columns.Add("Title", -1, HorizontalAlignment.Left) lvFiles.Columns.Add("Tree", 100, HorizontalAlignment.Left) lvFiles.Columns.Add("Name", -2, HorizontalAlignment.Left) End Sub




Reply With Quote