在Winform中使用ListView 和ImageList结合显示图片缩略图,但默认的间距太多,以下是设置上下、左右间距的方法:
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern Int32 SendMessage(IntPtr hwnd, Int32 wMsg, Int32 wParam, Int32 lParam);
const int LVM_FIRST = 0x1000;
const int LVM_SETICONSPACING = LVM_FIRST + 53;
//x 是左右间距,y是上下间距
private void SetInterval(int x,int y)
{
SendMessage(this.listView1.Handle, LVM_SETICONSPACING, 0, x * 65536 + y);
this.listView1.Refresh();
}