0
我正在使用圖像列表在列表視圖中顯示圖像。到目前爲止,我能夠顯示圖像列表中的所有圖像,但每個圖像之間的間距非常大。所以我用了Send Message method這引起了另一個問題。現在,當我單擊或移動鼠標(啓用熱追蹤)時,圖像變得不可見。我怎麼解決這個問題 ?如何調整列表視圖中圖像間的間距
Imports System.Runtime.InteropServices
Public Class Form1
<DllImport("user32.dll", CharSet:=CharSet.Auto, SetLastError:=False)> _
Private Shared Function SendMessage(ByVal hwnd As IntPtr, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32
End Function
Const LVM_FIRST As Integer = &H1000
Const LVM_SETICONSPACING As Integer = LVM_FIRST + 53
Public Sub SetSpacing(ByVal x As Int16, ByVal y As Int16)
SendMessage(Me.ListView1.Handle, LVM_SETICONSPACING, 0, x * 65536 + y)
Me.ListView1.Refresh()
End Sub
Private Sub Display()
For i As Integer = 0 To ImageList1.Images.Count - 1
Dim item As New ListViewItem()
item.ImageIndex = i
Me.ListView1.Items.Add(item)
Next
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Display()
SetSpacing(200, 16)
End Sub
End Class
鼠標移動之前:
移動鼠標後:
我也有這個大左旁雖然列表視圖頁邊距設置爲所有= 3
第一列圖像未被顯示!
'LVM_SETICONSPACING'僅適用於與 「圖標」 視圖樣式列表視圖。那是你正在使用的? – 2011-12-24 14:26:42
@CodyGray我正在使用Listview.View = LargeIcon – 2011-12-24 14:30:26