Problem with listview tile layout (vb.net)

I have a listview that displays (in the end) the itunes playlist album cover with the album name below it. The problem I am facing is that I cannot get the album art (currently an empty square). ABOVE album title. It's always on the side ... how can I do this? I tried adding column headers and sorting ...

to configure the watch list

Dim myImageList As ImageList albumList.View = View.Tile albumList.TileSize = New Size(120, 150) ' Initialize the item icons. myImageList = New ImageList() myImageList.Images.Add(Image.FromFile("c:/test.jpg")) myImageList.ImageSize = New Size(80, 80) albumList.LargeImageList = myImageList 

Then I do a loop to display each album name that uses

  Dim item0 As New ListViewItem(New String() _ {Albums(i).Name}, 0) albumList.Items.Add(item0) 

output http://i111.photobucket.com/albums/n122/mfacer/Screenshot2010-05-02at164815.png

but, as I said, I want the album title under the orange box ....

any ideas? Thanks for any info!

+4
source share
1 answer

This is a baked layout for viewing tiles. If you need labels below the images, you need to set View = LargeIcon. If this creates an unwanted distance between images, you can P / Invoke SendMessage () send the LVM_SETICONSPACING message. This worked well:

 using System; using System.Drawing; using System.Windows.Forms; using System.Runtime.InteropServices; class TileView : ListView { public TileView() { mSpacing = new Size(48, 48); } private Size mSpacing; public Size IconSpacing { get { return mSpacing; } set { mSpacing = value; updateSpacing(); } } protected override void OnHandleCreated(EventArgs e) { base.OnHandleCreated(e); updateSpacing(); } private void updateSpacing() { if (this.IsHandleCreated) { SendMessage(this.Handle, 0x1000 + 53, IntPtr.Zero, (IntPtr)((mSpacing.Height << 16) | mSpacing.Width)); } } [DllImport("user32.dll")] private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp); } 

Change the new IconSpacing property in the designer to work well with the size of images in your ImageList. You will immediately see the effect.


 Public Class TileView Inherits ListView Public Sub New() mSpacing = New Size(48, 48) End Sub Private mSpacing As Size Public Property IconSpacing As Size Get Return mSpacing End Get Set(ByVal value As Size) mSpacing = value updateSpacing() End Set End Property Protected Overrides Sub OnHandleCreated(ByVal e As System.EventArgs) MyBase.OnHandleCreated(e) updateSpacing() End Sub Private Sub updateSpacing() If Me.IsHandleCreated Then SendMessageW(Me.Handle, &H1000 + 53, IntPtr.Zero, CType((mSpacing.Height << 16) Or mSpacing.Width, IntPtr)) End If End Sub Private Declare Function SendMessageW Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wp As IntPtr, ByVal lp As IntPtr) As IntPtr End Class 
+7
source

Source: https://habr.com/ru/post/1308601/


All Articles