用于设置列表视图的代码
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
然后我做一个循环来显示使用的每个专辑名称
Dim item0 As New ListVIEwItem(New String() _ {Albums(i).name},0) albumList.Items.Add(item0)
输出是http://i111.photobucket.com/albums/n122/mfacer/Screenshot2010-05-02at164815.png
但正如我所说,我希望专辑名称在橙色框下面….
有任何想法吗??
感谢您的任何信息!
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);}
更改设计器中的新IconSpacing属性,以便与ImageList中的图像大小配合使用.你会立即看到效果.
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,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 IntPtrEnd Class总结
以上是内存溢出为你收集整理的listview tile layout问题(vb.net)全部内容,希望文章能够帮你解决listview tile layout问题(vb.net)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)